/* ==========================================================================
   SmartStudy Modern UI - Responsive Desktop & Mobile (Light & Dark Mode)
   ========================================================================== */
:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #eef2ff;
    --bg-muted: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success-soft: #ecfdf5;
    --danger-soft: #fef2f2;
    --warning-soft: #fffbeb;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 25px rgba(15, 23, 42, 0.08);
    --radius-md: 12px;
    --radius-lg: 16px;
    --bottom-nav-h: 64px;
}

[data-bs-theme="dark"] {
    --bg-body: #0b1120;
    --bg-card: #1e293b;
    --bg-subtle: rgba(99, 102, 241, 0.16);
    --bg-muted: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success-soft: rgba(16, 185, 129, 0.18);
    --danger-soft: rgba(239, 68, 68, 0.18);
    --warning-soft: rgba(245, 158, 11, 0.18);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.45);
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    line-height: 1.55;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header & Navigation */
.navbar-smart {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

[data-bs-theme="dark"] .navbar-smart {
    background-color: rgba(30, 41, 59, 0.9);
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.nav-pill-link {
    padding: 0.45rem 0.9rem !important;
    border-radius: 8px;
    color: var(--text-muted) !important;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.nav-pill-link:hover,
.nav-pill-link.active {
    color: var(--primary) !important;
    background-color: var(--bg-subtle);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    cursor: pointer;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--bg-subtle);
}

/* Cards */
.card-smart {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-smart.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(79, 70, 229, 0.35);
}

.stat-box {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-muted);
    border: 1px solid var(--border-color);
}

/* Buttons & Inputs */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.form-control,
.form-select {
    border-color: var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Quiz Option Buttons */
.option-btn {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 10px;
    transition: all 0.15s ease;
    cursor: pointer;
    line-height: 1.45;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--bg-subtle);
}

.option-btn.selected {
    border-color: var(--primary);
    background-color: var(--bg-subtle);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.option-btn.correct {
    border-color: #10b981 !important;
    background-color: var(--success-soft) !important;
}

.option-btn.wrong {
    border-color: #ef4444 !important;
    background-color: var(--danger-soft) !important;
}

.option-key-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--bg-muted);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.option-btn.selected .option-key-badge {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.option-btn.correct .option-key-badge {
    background-color: #10b981;
    border-color: #10b981;
    color: #fff;
}

.option-btn.wrong .option-key-badge {
    background-color: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

/* Question Navigation Grid */
.q-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 7px;
}

.q-nav-btn {
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.q-nav-btn:hover {
    border-color: var(--primary);
}

.q-nav-btn.current {
    border: 2px solid var(--primary);
    color: var(--primary);
}

.q-nav-btn.answered {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.q-nav-btn.flagged {
    background-color: #f59e0b !important;
    color: #ffffff !important;
    border-color: #d97706 !important;
}

/* Animations */
@keyframes pulseSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.012); }
    100% { transform: scale(1); }
}

@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
}

.anim-correct {
    animation: pulseSuccess 0.3s ease;
}

.anim-wrong {
    animation: shakeWrong 0.35s ease;
}

/* Leaderboard Podium */
.podium-card {
    position: relative;
    overflow: hidden;
}

.podium-gold {
    background: linear-gradient(135deg, rgba(254, 240, 138, 0.35) 0%, rgba(245, 158, 11, 0.15) 100%);
    border-color: #fbbf24;
}

.podium-silver {
    background: linear-gradient(135deg, rgba(241, 245, 249, 0.5) 0%, rgba(148, 163, 184, 0.18) 100%);
    border-color: #94a3b8;
}

.podium-bronze {
    background: linear-gradient(135deg, rgba(254, 215, 170, 0.35) 0%, rgba(234, 88, 12, 0.15) 100%);
    border-color: #fb923c;
}

/* Chat Box */
.chat-box {
    height: calc(100vh - 280px);
    min-height: 360px;
    max-height: 540px;
    overflow-y: auto;
    padding: 14px;
    background-color: var(--bg-muted);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.chat-item {
    padding: 10px 14px;
    border-radius: 12px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    box-shadow: var(--shadow-xs);
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 1030;
    padding: 0 6px;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.05);
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    height: 100%;
    transition: color 0.15s ease;
}

.mobile-nav-item i {
    font-size: 1.15rem;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
    color: var(--primary);
}

/* Confetti */
.confetti-piece {
    position: fixed;
    top: -12px;
    width: 9px;
    height: 16px;
    z-index: 9999;
    pointer-events: none;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    to {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive adjustments for Mobile & Tablet */
@media (max-width: 991.98px) {
    body {
        padding-bottom: calc(var(--bottom-nav-h) + 12px);
    }
    .mobile-bottom-nav {
        display: flex;
    }
    .desktop-footer {
        display: none;
    }
    .quiz-sticky-panel {
        position: static !important;
    }
}

@media (max-width: 575.98px) {
    .container {
        padding-left: 14px;
        padding-right: 14px;
    }
    .card-smart {
        border-radius: 14px;
    }
    .option-btn {
        padding: 11px 13px;
        font-size: 0.9rem;
    }
    .option-key-badge {
        width: 28px;
        height: 28px;
        margin-right: 10px;
        font-size: 0.8rem;
    }
    .chat-box {
        height: calc(100vh - 300px);
        min-height: 300px;
    }
}
