/**
 * Component Styles - EduPlatform (Modern UI/UX Glassmorphism & Micro-animations)
 */

/* Navbar - Fixed & Sticky Modern Glassmorphism */
.app-navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid var(--border-color) !important;
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1050 !important;
    transition: box-shadow 0.25s ease, background 0.25s ease;
    padding: 0.35rem 0 !important;
    min-height: 54px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06) !important;
}

.brand-logo {
    font-size: 1.12rem !important;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    text-decoration: none;
}

.brand-badge {
    font-size: 0.58rem !important;
    padding: 0.12rem 0.45rem !important;
    border-radius: 20px;
    background: #fef3c7 !important;
    color: #92400e !important;
    -webkit-text-fill-color: #92400e !important;
    font-weight: 800 !important;
    letter-spacing: 0.4px;
    white-space: nowrap;
    display: inline-block;
    border: 1px solid #fde68a !important;
}

.app-navbar .nav-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.2rem !important;
    white-space: nowrap !important;
    font-size: 0.81rem !important;
    font-weight: 600 !important;
    padding: 0.25rem 0.42rem !important;
    border-radius: 6px;
    color: #334155 !important;
    transition: all 0.15s ease;
}

@media (min-width: 1400px) {
    .app-navbar .nav-link {
        font-size: 0.85rem !important;
        padding: 0.3rem 0.55rem !important;
    }
}

.app-navbar .nav-link:hover {
    background: rgba(79, 70, 229, 0.08) !important;
    color: var(--primary) !important;
}

.app-navbar .nav-link i {
    font-size: 0.88rem !important;
}

/* Tablet Horizontal Menu (992px - 1399px): Show all menu items on 1 row without wrapping or hiding */
@media (min-width: 992px) and (max-width: 1399.98px) {
    .app-navbar .navbar-nav {
        gap: 0.15rem !important;
    }

    .app-navbar .nav-link {
        font-size: 0.78rem !important;
        padding: 0.22rem 0.35rem !important;
        gap: 0.15rem !important;
    }

    .app-navbar .nav-link i {
        font-size: 0.82rem !important;
    }

    .app-navbar .brand-logo {
        font-size: 1.02rem !important;
        gap: 0.25rem !important;
    }

    .app-navbar .btn {
        padding: 0.22rem 0.55rem !important;
        font-size: 0.78rem !important;
    }

    .app-navbar .theme-toggle-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.95rem !important;
    }
}

/* Mobile Only Collapsible Drawer Menu (< 992px) */
@media (max-width: 991.98px) {
    .app-navbar .navbar-collapse {
        background: var(--bg-surface);
        padding: 1rem 1.25rem;
        border-radius: var(--radius-lg);
        margin-top: 0.5rem;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
        border: 1px solid var(--border-color);
        max-height: 80vh;
        overflow-y: auto;
    }

    .app-navbar .navbar-nav {
        gap: 0.35rem !important;
        margin-bottom: 1rem !important;
    }

    .app-navbar .nav-link {
        display: flex !important;
        align-items: center !important;
        padding: 0.6rem 0.85rem !important;
        font-size: 0.95rem !important;
        border-radius: var(--radius-md);
    }

    .app-navbar .dropdown-menu {
        background: #f8fafc;
        border: 1px solid var(--border-color);
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        margin-top: 0.25rem;
    }

    .app-navbar .ms-auto,
    .app-navbar .ms-xxl-auto {
        margin-left: 0 !important;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
        flex-wrap: wrap;
    }
}

/* Glassmorphism Cards */
.card-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card-glass:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
    transform: translateY(-3px);
}

/* Custom Buttons */
.btn-primary-custom {
    background: var(--primary-gradient);
    color: #ffffff !important;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
    color: #ffffff !important;
}

.btn-outline-custom {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-outline-custom:hover {
    background: var(--bg-main);
    border-color: var(--primary);
    color: var(--primary);
}

/* Gamification Widgets - Slim Modern Micro-Pills */
.streak-badge, .xp-badge, .level-badge {
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    padding: 0.22rem 0.6rem !important;
    border-radius: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.3rem !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.xp-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.25);
}

.level-badge {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.25);
}

.streak-badge {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(249, 115, 22, 0.25);
}

.user-nav-btn {
    padding: 0.25rem 0.75rem !important;
    font-size: 0.85rem !important;
    border-radius: 20px !important;
    background: #ffffff !important;
    border: 1.5px solid var(--border-color) !important;
    white-space: nowrap !important;
}

/* Stats Pill */
.stat-pill {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-pill:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.stat-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Form Controls */
.form-control-custom {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: var(--bg-surface);
}

.form-control-custom:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

/* Progress bar */
.progress-custom {
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--border-color);
    overflow: hidden;
}

.progress-bar-custom {
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

/* Hero Section */
.hero-wrapper {
    position: relative;
    padding: 2rem 0;
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: 0;
    pointer-events: none;
}

/* Interactive Color Cards & Speech Audio Elements */
.hover-scale {
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease !important;
}

.hover-scale:hover {
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12) !important;
}

.hover-scale:active {
    transform: scale(0.96);
}

.cursor-pointer {
    cursor: pointer !important;
}

/* Theme Toggle Button (Light/Dark Switcher) */
.theme-toggle-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-surface) !important;
    color: var(--text-main) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
    transform: rotate(20deg) scale(1.08);
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* ==========================================================================
   Dark Mode Component Overrides
   ========================================================================== */
[data-theme="dark"],
[data-bs-theme="dark"],
body.dark-mode {
    background-color: #0b0f19 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .app-navbar,
[data-bs-theme="dark"] .app-navbar,
body.dark-mode .app-navbar {
    background: rgba(11, 15, 25, 0.92) !important;
    border-bottom: 1px solid #1e293b !important;
}

[data-theme="dark"] .app-navbar .nav-link,
[data-bs-theme="dark"] .app-navbar .nav-link,
body.dark-mode .app-navbar .nav-link {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .app-navbar .nav-link:hover,
[data-bs-theme="dark"] .app-navbar .nav-link:hover,
body.dark-mode .app-navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .card:not([style*="background: linear-gradient"]),
[data-bs-theme="dark"] .card:not([style*="background: linear-gradient"]),
body.dark-mode .card:not([style*="background: linear-gradient"]) {
    background-color: #131b2e !important;
    border-color: #1e293b !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .card-glass,
[data-bs-theme="dark"] .card-glass,
body.dark-mode .card-glass {
    background: rgba(19, 27, 46, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-white,
body.dark-mode .bg-white {
    background-color: #131b2e !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-light,
body.dark-mode .bg-light {
    background-color: #1a233a !important;
    color: #cbd5e1 !important;
    border-color: #1e293b !important;
}

[data-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-dark,
body.dark-mode .text-dark {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-muted,
body.dark-mode .text-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom {
    border-color: #1e293b !important;
}

[data-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .dropdown-menu,
body.dark-mode .dropdown-menu {
    background-color: #162036 !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .dropdown-item,
[data-bs-theme="dark"] .dropdown-item,
body.dark-mode .dropdown-item {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:hover,
body.dark-mode .dropdown-item:hover {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

[data-theme="dark"] .modal-content,
[data-bs-theme="dark"] .modal-content,
body.dark-mode .modal-content {
    background-color: #131b2e !important;
    color: #f1f5f9 !important;
    border: 1px solid #1e293b !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #0b0f19 !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background-color: #0f172a !important;
    border-color: #6366f1 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .exam-option-card,
[data-bs-theme="dark"] .exam-option-card,
body.dark-mode .exam-option-card {
    background: #162036 !important;
    border-color: #1e293b !important;
}

[data-theme="dark"] .exam-option-card:hover,
[data-bs-theme="dark"] .exam-option-card:hover,
body.dark-mode .exam-option-card:hover {
    background: #1e293b !important;
    border-color: #6366f1 !important;
}

[data-theme="dark"] .exam-option-card:has(input:checked),
[data-bs-theme="dark"] .exam-option-card:has(input:checked),
body.dark-mode .exam-option-card:has(input:checked) {
    background: #1e1b4b !important;
    border-color: #818cf8 !important;
}

[data-theme="dark"] .app-footer,
[data-bs-theme="dark"] .app-footer,
body.dark-mode .app-footer {
    background: #070a12 !important;
    border-top: 1px solid #1e293b !important;
}

/* ==============================================================================
   Textbook-Quality Vertical Math Fractions (Chuẩn phân số trên - dưới)
   ============================================================================== */
.katex {
    font-size: 1.22em !important;
    text-rendering: auto;
}

.katex-rendered-math {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0.2rem;
}

/* Flexbox Equation Container ensuring 100% horizontal alignment for =, +, -, × */
.math-equation-row, .math-expr-row {
    display: inline-flex !important;
    align-items: center !important;
    vertical-align: middle !important;
    gap: 0.35rem !important;
    color: #1e293b !important;
    font-weight: 600 !important;
    font-family: inherit !important;
}

.math-equation-row code, .math-expr-row code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
}

.math-op {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.15em !important;
    line-height: 1 !important;
    font-weight: 700;
    margin: 0 0.15rem;
}

.math-frac, .fraction-vertical {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    text-align: center !important;
    padding: 0 0.22rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    font-family: inherit !important;
    color: inherit;
    text-decoration: none !important;
    box-sizing: border-box;
}

.math-frac .num, .fraction-vertical .num {
    border-bottom: 2px solid currentColor !important;
    padding-bottom: 2px !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
    display: block !important;
    min-width: 0.85em !important;
    text-align: center !important;
    font-size: 0.9em !important;
}

.math-frac .den, .fraction-vertical .den {
    padding-top: 2px !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
    display: block !important;
    min-width: 0.85em !important;
    text-align: center !important;
    font-size: 0.9em !important;
}

/* Hỗn số (Mixed numbers) */
.mixed-number {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.2rem !important;
    font-weight: 700;
}
.mixed-number .whole {
    font-size: 1.1em;
    font-weight: 800;
}

/* ==========================================================================
   Child-Friendly Answer Option Audio Speaker Buttons (.btn-opt-speak)
   ========================================================================== */
.btn-opt-speak {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #2563eb !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
}

.btn-opt-speak:hover {
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    color: #1d4ed8 !important;
    transform: scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
}

.btn-opt-speak:active {
    transform: scale(0.95) !important;
}

.btn-opt-speak.is-speaking {
    background: #dbeafe !important;
    border-color: #2563eb !important;
    color: #1d4ed8 !important;
    animation: speaker-pulse 1.1s infinite cubic-bezier(0.4, 0, 0.6, 1) !important;
    transform: scale(1.18) !important;
}

.btn-opt-speak.btn-opt-speak-sm {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    font-size: 0.85rem !important;
}

@keyframes speaker-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* Dark theme overrides */
[data-bs-theme="dark"] .btn-opt-speak {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #60a5fa !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

[data-bs-theme="dark"] .btn-opt-speak:hover {
    background: #334155 !important;
    border-color: #60a5fa !important;
    color: #93c5fd !important;
    box-shadow: 0 4px 14px rgba(96, 165, 250, 0.3) !important;
}

[data-bs-theme="dark"] .btn-opt-speak.is-speaking {
    background: #1e3a8a !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
    animation: speaker-pulse-dark 1.1s infinite cubic-bezier(0.4, 0, 0.6, 1) !important;
}

@keyframes speaker-pulse-dark {
    0% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(96, 165, 250, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
    }
}

/* Visual Vocabulary Illustration Cards (What is this?) */
.question-visual-illustration {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.25rem 0;
}

.vocab-visual-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    border-radius: 1.25rem;
    padding: 1.25rem 1.75rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
    width: 100%;
}

.vocab-visual-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(37, 99, 235, 0.15), 0 8px 10px -4px rgba(37, 99, 235, 0.08);
    border-color: #93c5fd;
}

.vocab-visual-card img,
.vocab-visual-card svg {
    max-height: 180px;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.12));
    transition: transform 0.3s ease;
}

.vocab-visual-card:hover img,
.vocab-visual-card:hover svg {
    transform: scale(1.05);
}

[data-bs-theme="dark"] .vocab-visual-card {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .vocab-visual-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 20px 30px -10px rgba(59, 130, 246, 0.25);
}

