/* ChemBuddy - Common Styles */

/* === Variables === */
:root {
    --primary: #1a5f7a;
    --primary-dark: #0d3d4d;
    --primary-light: #2980b9;
    --secondary: #57c5b6;
    --secondary-light: #7dd8cc;
    --accent: #159895;
    --bg: #f8f9fa;
    --bg-dark: #e9ecef;
    --text: #2c3e50;
    --text-light: #6c757d;
    --text-muted: #adb5bd;
    --white: #ffffff;
    --border: #dee2e6;
    --hover: #e8f4f8;
    --success: #27ae60;
    --success-light: #d4edda;
    --danger: #e74c3c;
    --danger-light: #f8d7da;
    --warning: #f39c12;
    --warning-light: #fff3cd;
    --info: #3498db;
    --gold: #f1c40f;
    --silver: #95a5a6;
    --bronze: #cd6133;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50%;
    --transition: 0.2s ease;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* === Typography === */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--text-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover:not(:disabled) { background: var(--accent); }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover:not(:disabled) { background: #219a52; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: var(--radius-full);
    background: transparent; border: none;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--hover); }

/* === Form Elements === */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}
.form-input, .form-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* === Cards === */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-body { padding: 1.25rem; }
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-primary { background: rgba(26, 95, 122, 0.1); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-gold { background: #fef9e7; color: #b7950b; }
.badge-silver { background: #f2f3f4; color: #717d7e; }
.badge-bronze { background: #fbeee6; color: #a04000; }

/* === Progress Bar === */
.progress {
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-lg { height: 12px; }
.progress-lg .progress-bar { border-radius: 6px; }

/* === Stat Cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}
.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* === Toast Notifications === */
.cb-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
}
.cb-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.cb-toast-info { background: var(--primary); color: var(--white); }
.cb-toast-success { background: var(--success); color: var(--white); }
.cb-toast-error { background: var(--danger); color: var(--white); }
.cb-toast-warning { background: var(--warning); color: var(--white); }

/* === Loading Spinner === */
.cb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-light);
}
.cb-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Modal === */
.cb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 1rem;
}
.cb-modal-overlay.show { opacity: 1; }
.cb-modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.2s;
}
.cb-modal-overlay.show .cb-modal { transform: scale(1); }
.cb-modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cb-modal-body { padding: 1.25rem; }
.cb-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-light);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text); }

/* === Utility Classes === */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.w-full { width: 100%; }

/* === Responsive === */
@media (max-width: 768px) {
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
