/* Base & Typography */
html {
    scroll-behavior: smooth;
}

:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.7);
    --panel-border: #30363d;
    --text-primary: #c9d1d9;
    --text-dim: #8b949e;
    --accent-color: #58a6ff;
    --accent-hover: #3182ce;
    --success-color: #238636;
    --danger-color: #f85149;
    --warning-color: #d29922;
    --info-color: #3b82f6;
    --highlight: #2ea043;
    --font-family: 'Inter', sans-serif;
    --glass-blur: blur(10px);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-color: #f0f4f8;
    --panel-bg: #ffffff;
    --panel-border: #eef0f2;
    --text-primary: #1e293b;
    --text-dim: #64748b;
    --accent-color: #14b8a6; /* Teal */
    --accent-hover: #0d9488;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --highlight: #14b8a6;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center { text-align: center; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.py-5 { padding-top: 3rem; padding-bottom: 3rem; }
.p-3 { padding: 1rem; }
.rounded { border-radius: 8px; }
.d-flex { display: flex; }
.space-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.fw-bold { font-weight: 600; }
.text-dim { color: var(--text-dim); }

/* Grid Systems */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.grid-fill {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Navigation */
.navbar {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.brand-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.brand-logo span {
    color: var(--accent-color);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-align: center;
    font-family: var(--font-family);
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--accent-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background-color: var(--panel-border);
    color: #666;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-outline:hover {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-color);
}

.btn-success {
    background-color: var(--success-color);
    color: #fff;
}

.btn-success:hover {
    background-color: #2ea043;
    color: #fff;
}

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-large { padding: 0.8rem 1.6rem; font-size: 1.1rem; }
.btn-block { display: block; width: 100%; box-sizing: border-box; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--panel-border);
}
.badge-premium { background: var(--warning-color); color: #fff; }
.badge-free { background: var(--text-dim); color: #fff; }

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Flash Messages as Toasts */
.flash-messages { 
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Let clicks pass through empty space */
}
.flash {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 4px solid;
    background: var(--surface-bg, #1a1e23);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
    animation: slideInUp 0.4s ease forwards;
    pointer-events: auto; /* Re-enable clicks on the toast itself */
}
@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.flash-success { border-color: var(--success-color); color: var(--success-color); }
.flash-danger { border-color: var(--danger-color); color: var(--danger-color); }
.flash-warning { border-color: var(--warning-color); color: var(--warning-color); }
.flash-info { border-color: var(--info-color); color: var(--info-color); }
.flash-message { border-color: var(--text-primary); color: var(--text-primary); }

/* Auth Forms */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
}

.auth-subtitle {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3);
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
}

/* Exam UI */
.exam-container { max-width: 800px; }

.progress-container {
    background: var(--panel-border);
    border-radius: 4px;
    height: 8px;
    margin-top: 1rem;
    overflow: hidden;
}

.progress-container .fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.3s ease;
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(22, 27, 34, 0.4);
}

.choice-item:hover {
    border-color: var(--text-dim);
    background: rgba(48, 54, 61, 0.4);
}

.choice-item.selected {
    border-color: var(--accent-color);
    background: rgba(88, 166, 255, 0.1);
}

.choice-item.correct {
    border-color: var(--success-color);
    background: rgba(35, 134, 54, 0.1);
}

.choice-item.incorrect {
    border-color: var(--danger-color);
    background: rgba(248, 81, 73, 0.1);
}

.choice-letter {
    font-weight: 600;
    margin-right: 15px;
    background: var(--panel-border);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.choice-explanation {
    border-top: 1px solid var(--panel-border);
    padding-top: 0.5rem;
    color: var(--text-primary);
    width: 100%;
}

.choice-item {
    flex-wrap: wrap;
}

.choice-text {
    flex: 1;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* Pricing Cards */
.pricing-header { padding: 4rem 0 2rem; }
.pricing-header h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.pricing-header .subtitle { font-size: 1.2rem; color: var(--text-dim); }

.price-card {
    position: relative;
    display: flex;
    flex-direction: column;
}

.price-card .card-header {
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 1.5rem;
}

.price-card .price {
    font-size: 3rem;
    font-weight: 700;
    margin: 1rem 0;
}

.price-card .price span {
    font-size: 1rem;
    color: var(--text-dim);
    font-weight: 400;
}

.features-list {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
    flex: 1;
}

.features-list li {
    padding: 0.5rem 0;
    color: var(--text-primary);
}

.features-list i.icon-check { color: var(--success-color); font-style: normal; margin-right: 8px;}
.features-list i.icon-cross { color: var(--danger-color); font-style: normal; margin-right: 8px;}

.highlight-border {
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.1);
}

.premium-card .badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: white;
}

/* Footer */
.footer {
    border-top: 1px solid var(--panel-border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-dim);
    margin-top: auto;
}

/* Premium Dashboard Layout (V1.3.1 Hotfix) */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.dashboard-sidebar {
    width: 250px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(20, 184, 166, 0.05); /* Teal overlay */
    color: var(--accent-color);
    border-right: 3px solid var(--accent-color);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--panel-border);
}

.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
}

.dashboard-topbar {
    height: 70px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.dashboard-content {
    padding: 2.5rem 2rem;
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.usage-meter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.progress-bar-container {
    background: var(--panel-border);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.bg-accent { background-color: var(--accent-color); }
.bg-success { background-color: var(--success-color); }

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    position: relative;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; }

.modal-body {
    padding: 2rem;
}

.close-modal {
    color: var(--text-dim);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-primary);
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 1rem) center;
    padding-right: 2.5rem;
}

[data-theme="light"] .form-control {
    background: #fff;
}

.gap-3 { gap: 1rem; }
.justify-content-center { justify-content: center; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Base layout */
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 0 15px;
    }

    /* Typography */
    .hero-title {
        font-size: 2rem;
    }
    .pricing-header h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    
    /* Global Navigation */
    .navbar {
        position: relative;
    }
    .nav-container {
        align-items: center;
    }
    .mobile-menu-toggle {
        display: block !important;
        margin-left: auto;
    }
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background-color: #0d1117 !important; /* Force solid background for mobile visibility */
        border-bottom: 1px solid var(--panel-border);
        padding: 1rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
        box-sizing: border-box;
        z-index: 1000;
    }

    [data-theme="light"] .nav-links {
        background-color: #ffffff !important; /* Force solid white for Light Mode */
    }
    .nav-links.show {
        display: flex;
    }
    .nav-links li {
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    /* Dashboard Layout */
    .dashboard-wrapper {
        flex-direction: column;
    }
    .dashboard-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }
    .dashboard-sidebar.show {
        left: 0;
    }
    .dashboard-topbar {
        padding: 0 1rem;
    }
    .mobile-sidebar-toggle {
        display: block !important;
    }
    .dashboard-content {
        padding: 1.5rem 1rem;
    }

    /* Other elements */
    .auth-container {
        margin: 2rem auto;
        padding: 0 15px;
        width: 100%;
    }
    
    /* Profile Forms Grid */
    .profile-container .grid {
        grid-template-columns: 1fr !important;
    }

    /* Exam List items */
    .exam-list-item {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    .exam-actions {
        width: 100%;
        flex-direction: column;
        align-items: flex-start !important;
    }
    .exam-actions .btn {
        width: 100%;
    }
    .exam-stats.text-right {
        text-align: left !important;
        margin-bottom: 0.5rem;
    }
}

/* Fix pale native select dropdowns in dark mode */
select.form-control,
select.form-control option,
select.form-control optgroup {
    background-color: var(--panel-bg);
    color: var(--text-primary);
}
/* Verification Banner */
.verification-banner {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid #fde68a;
    position: sticky;
    top: 0;
    z-index: 10000;
    width: 100%;
    box-sizing: border-box;
}

.verification-banner .banner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    max-width: 1200px;
    margin: 0 auto;
}

.verification-banner a {
    color: #92400e;
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.2s;
}

.verification-banner a:hover {
    color: #b45309;
}

.verification-banner i {
    font-style: normal;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .verification-banner {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

/* --- Glossary Components --- */
.glossary-section {
    margin-bottom: 3rem;
}

.term-card {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.term-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.search-form .form-control {
    border-radius: 20px;
    background: var(--panel-bg);
}

.search-form .form-control:focus {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.term-content .glass-panel {
    padding: 2.5rem;
}

.hover-primary:hover {
    color: var(--accent-color) !important;
}

/* Answer Engine Optimization (AEO) styling for the primary definition */
.atomic-answer {
    font-weight: 500;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .term-content .glass-panel {
        padding: 1.5rem;
    }
}

/* --- Blog Components --- */
.blog-section {
    margin-bottom: 3rem;
}

.blog-card {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.blog-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.category-badge {
    display: inline-block;
    padding: 0.2em 0.7em;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(88, 166, 255, 0.1));
    color: var(--accent-color);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.text-xs { font-size: 0.75rem; }

.blog-post-content .glass-panel {
    padding: 2.5rem;
}

.blog-post-content h2 {
    color: var(--text-primary);
}

.blog-post-content p {
    color: var(--text-primary);
    opacity: 0.9;
}

.blog-meta {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
}

.blog-sidebar .glass-panel {
    transition: box-shadow 0.3s ease;
}

.blog-sidebar .glass-panel:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .blog-post-content .glass-panel {
        padding: 1.5rem;
    }
    .blog-sidebar {
        order: -1;
        margin-bottom: 2rem;
    }
    .blog-sidebar .glass-panel {
        position: static !important;
    }
}

/* --- Bidirectional Auto-Linking --- */
.glossary-auto-link {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: rgba(88, 166, 255, 0.5);
    text-underline-offset: 3px;
    transition: all 0.2s ease;
}

.glossary-auto-link:hover {
    color: #fff;
    text-decoration-style: solid;
    text-decoration-color: var(--accent-color);
    background: rgba(88, 166, 255, 0.1);
    border-radius: 2px;
}
