/* * EduManage Premium Design System 
 * Typography: Plus Jakarta Sans (loaded via <link> in includes/header.php)
 */

:root {
    /* Core Brand Colors */
    --primary: #4f46e5; /* Indigo 600 - Premium, Trustworthy */
    --primary-hover: #4338ca;
    --secondary: #10b981; /* Emerald 500 - Success, Growth */
    --accent: #f59e0b; /* Amber 500 - gamification */
    --accent-glow: rgba(245, 158, 11, 0.4);

    /* Bootstrap 5.3 Brand Token Overrides */
    --bs-primary: var(--primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-success: #10b981;
    --bs-success-rgb: 16, 185, 129;
    --bs-link-color: var(--primary);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--primary-hover);
    --bs-link-hover-color-rgb: 67, 56, 202;

    /* Playful Colors (For Games & Student Hub) */
    --playful-pink: #ec4899;
    --playful-purple: #8b5cf6;
    --playful-blue: #3b82f6;

    /* Surfaces & Backgrounds */
    --bg-main: #f8fafc; /* Slate 50 - Very soft, cool grey/blue background */
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.85);

    /* Text */
    --text-main: #0f172a; /* Slate 900 - High contrast */
    --text-muted: #64748b; /* Slate 500 - Secondary text */

    /* Borders & Shadows */
    --border-light: rgba(226, 232, 240, 0.8);
    --shadow-soft:
        0 10px 25px -5px rgba(0, 0, 0, 0.05),
        0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --shadow-float:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Base Typography Override */
body {
    font-family:
        "Plus Jakarta Sans",
        system-ui,
        -apple-system,
        sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

/* In premium_theme.css — enhance the background so glass effect shows */
body.bg-main {
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #ecfdf5 100%);
    background-attachment: fixed;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: inherit;
}

.text-white :is(h1, h2, h3, h4, h5, h6),
.text-white h1,
.text-white h2,
.text-white h3,
.text-white h4,
.text-white h5,
.text-white h6 {
    color: inherit;
}

/* =========================================
   PREMIUM COMPONENTS (Admin/Teacher)
   ========================================= */

.premium-card {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-card-interactive:hover {
    box-shadow: var(--shadow-float);
    transform: translateY(-2px);
}

.premium-card .card-header {
    background: transparent;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid var(--border-light);
    padding: 1.5rem;
    font-weight: 700;
}

.premium-card .card-footer {
    background: transparent;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid var(--border-light);
    padding: 1.5rem;
    /* font-weight: 700; */
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

/* =========================================
   PLAYFUL COMPONENTS (Student Hub & Games)
   ========================================= */

.playful-card {
    background: var(--surface);
    border-radius: 24px; /* More rounded for playful feel */
    border: 2px solid transparent;
    box-shadow: var(--shadow-soft);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy hover */
    overflow: hidden;
    position: relative;
}

.playful-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.playful-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(
        90deg,
        var(--playful-pink),
        var(--playful-purple),
        var(--playful-blue)
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.playful-card:hover::before {
    opacity: 1;
}

/* Gradient Text for Gamification Headers */
.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(
        135deg,
        var(--primary),
        var(--playful-purple)
    );
    font-weight: 800;
}

/* =========================================
   BUTTONS & INPUTS
   ========================================= */

.btn-premium {
    background-color: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    border: none;
    box-shadow:
        0 4px 6px -1px rgba(79, 70, 229, 0.2),
        0 2px 4px -1px rgba(79, 70, 229, 0.1);
    transition: all 0.2s ease;
}

.btn-premium:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow:
        0 10px 15px -3px rgba(79, 70, 229, 0.3),
        0 4px 6px -2px rgba(79, 70, 229, 0.15);
    color: white;
}

.btn-playful {
    background: linear-gradient(
        135deg,
        var(--playful-pink),
        var(--playful-purple)
    );
    color: white;
    border-radius: 50px; /* Pill shape */
    padding: 0.75rem 2rem;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-playful:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(236, 72, 153, 0.6);
    color: white;
}

.form-control,
.form-select {
    border-radius: 12px;
    border: 1px solid var(--border-light);
    padding: 0.75rem 1rem;
    background-color: var(--surface);
    transition: all 0.2s ease;
}

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

/* =========================================
   NAVBAR MODIFICATIONS
   ========================================= */

.navbar-glass {
    background: var(--surface-glass) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.navbar-glass .navbar-brand {
    color: var(--primary) !important;
    font-weight: 800;
    letter-spacing: -0.05em;
    font-size: 1.5rem;
}

.navbar-glass .nav-link {
    color: var(--text-muted) !important;
    font-weight: 600;
    transition: color 0.2s ease;
}

.navbar-glass .nav-link:hover {
    color: var(--primary) !important;
}

/* ════════════════════════════════════════════════════════════════════
   POLISH SPRINT — MathJax anti-layout-shift + mobile sidebar FAB
   ════════════════════════════════════════════════════════════════════ */

/* Math zones stay invisible (but keep their space) until MathJax has
   typeset the page; the header script adds .has-mathjax + .mathjax-ready to <body>.
   A 2.5s failsafe guarantees content is never stuck hidden. */
body.has-mathjax:not(.mathjax-ready) .math-zone {
    visibility: hidden;
    min-height: 80px;
}
.mathjax-ready .math-zone {
    visibility: visible;
    animation: eduMathFadeIn 0.25s ease-in;
}
@keyframes eduMathFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Floating menu button for the mobile offcanvas sidebar */
.edu-sidebar-fab {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 1080;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BATCH 6 — Notification bell dropdown
   ═══════════════════════════════════════════════════════════════ */
.notif-dropdown {
    width: 340px;
    max-width: 90vw;
    overflow: hidden;
}
.notif-scroll {
    max-height: 380px;
    overflow-y: auto;
}
.notif-item {
    white-space: normal;
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.15s ease;
}
.notif-item:last-child {
    border-bottom: 0;
}
.notif-dropdown .notif-item {
    padding-left: 1.4rem !important;
}
.notif-unread-dot {
    position: absolute;
    left: 9px;
    top: 16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}
.notif-body-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   BATCH 8 — Curriculum taxonomy: topic chips (manage_books.php,
   later reused by the practice-quiz topic picker in Part 2)
   ═══════════════════════════════════════════════════════════════ */
.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #ffffff;
    border: 1px solid rgba(79, 70, 229, 0.25);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
}
.topic-chip .btn-link {
    line-height: 1;
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════
   BATCH 10 — Streak engine: dashboard streak tiles
   States: .active (alive today) · .pending (yesterday — act today)
           .at_risk (shield armed) · .broken / .none (grey)
   ═══════════════════════════════════════════════════════════════ */
.streak-tile {
    height: 100%;
    padding: 10px 6px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
}
.streak-tile .streak-flame {
    font-size: 1.5rem;
    color: #cbd5e1; /* unlit — broken/none */
}
.streak-tile.active .streak-flame {
    color: var(--accent);
    animation: streakFlicker 1.6s ease-in-out infinite;
}
.streak-tile.pending .streak-flame {
    color: #fbbf24;
    opacity: 0.55;
}
.streak-tile.at_risk .streak-flame {
    color: #ef4444;
    animation: streakFlicker 0.8s ease-in-out infinite;
}
.streak-count {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.1;
}
.streak-hint {
    font-size: 0.65rem;
    font-weight: 600;
}
@keyframes streakFlicker {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.12);
    }
}

/* ═══════════════════════════════════════════════════════════════
   BATCH 11 — AI Question Generator: review cards
   ═══════════════════════════════════════════════════════════════ */
.ai-q-card {
    border-left: 3px solid var(--primary);
}
.ai-q-card:has(.ai-include:not(:checked)) {
    opacity: 0.45;
    border-left-color: #cbd5e1;
}

/* ═══════════════════════════════════════════════════════════════
   BATCH 12 — Class Insights: per-signal chips
   ═══════════════════════════════════════════════════════════════ */
.risk-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: help;
}
.risk-chip-good {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}
.risk-chip-mid {
    background: rgba(245, 158, 11, 0.14);
    color: #92400e;
}
.risk-chip-bad {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}
.risk-chip-null {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

/* ═══════════════════════════════════════════════════════════════════
   BATCH 14 — Courses 2.0 player
   ═══════════════════════════════════════════════════════════════════ */

/* Markdown lesson prose */
.prose-content { line-height: 1.85; font-size: 1.05rem; color: #1f2937; }
.prose-content h1, .prose-content h2, .prose-content h3, .prose-content h4 {
    font-weight: 800; color: #111827; margin: 1.6em 0 .6em; line-height: 1.3;
}
.prose-content h1 { font-size: 1.7rem; }
.prose-content h2 { font-size: 1.4rem; padding-bottom: .3em; border-bottom: 2px solid rgba(79,70,229,.12); }
.prose-content h3 { font-size: 1.15rem; }
.prose-content p  { margin-bottom: 1.1em; }
.prose-content ul, .prose-content ol { margin-bottom: 1.1em; padding-left: 1.4em; }
.prose-content li { margin-bottom: .35em; }
.prose-content img { max-width: 100%; border-radius: .75rem; box-shadow: 0 4px 16px rgba(0,0,0,.08); margin: 1em 0; }
.prose-content blockquote {
    border-left: 4px solid var(--primary); background: rgba(79,70,229,.05);
    padding: .8em 1.2em; border-radius: 0 .5rem .5rem 0; margin: 1.2em 0; color: #4b5563;
}
.prose-content code {
    background: rgba(79,70,229,.08); color: #4338ca; padding: .15em .45em;
    border-radius: .35rem; font-size: .88em;
}
.prose-content pre {
    background: #111827; color: #e5e7eb; padding: 1em 1.2em; border-radius: .75rem;
    overflow-x: auto; margin: 1.2em 0;
}
.prose-content pre code { background: none; color: inherit; padding: 0; }
.prose-content table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .95rem; }
.prose-content th, .prose-content td { border: 1px solid #e5e7eb; padding: .55em .8em; text-align: left; }
.prose-content th { background: rgba(79,70,229,.06); font-weight: 700; }
.prose-content hr { border: 0; border-top: 2px solid rgba(0,0,0,.06); margin: 2em 0; }

/* Course sidebar / curriculum nav */
.course-sidebar { position: sticky; top: 80px; max-height: calc(100vh - 120px); overflow-y: auto; }
.lesson-link {
    display: block; padding: .5rem .75rem; border-radius: .5rem;
    text-decoration: none; color: #374151; font-size: .875rem; transition: background .15s;
}
.lesson-link:hover { background: rgba(79,70,229,.06); }
.lesson-link.active { background: rgba(79,70,229,.12); color: var(--primary); font-weight: 700; }
.lesson-link.done .lesson-icon { color: var(--secondary); }
.lesson-link.locked { opacity: .5; cursor: not-allowed; }
.module-toggle { background: transparent; border-radius: .5rem; }
.module-toggle:hover { background: rgba(0,0,0,.03); }
.module-toggle .module-chev { transition: transform .2s; }
.module-toggle.collapsed .module-chev { transform: rotate(-90deg); }

/* Checkpoint quiz player */
.quiz-question { background: #fff; transition: border-color .2s, background .2s; }
.quiz-question.q-correct { border-color: var(--secondary) !important; background: rgba(16,185,129,.05); }
.quiz-question.q-wrong   { border-color: #ef4444 !important;        background: rgba(239,68,68,.04); }
.quiz-option { cursor: pointer; transition: border-color .15s, background .15s; background: #fff; }
.quiz-option:hover { border-color: var(--primary) !important; background: rgba(79,70,229,.04); }
.quiz-option:has(input:checked) { border-color: var(--primary) !important; background: rgba(79,70,229,.08); }
.quiz-explain { background: rgba(0,0,0,.03); }

/* Course-complete confetti */
.em-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2000; overflow: hidden; }
.em-confetti span {
    position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px;
    opacity: .95; animation: em-confetti-fall linear forwards;
}
@keyframes em-confetti-fall {
    to { transform: translateY(105vh) rotate(720deg); opacity: .7; }
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 1 — Shared Design System, Bootstrap Indigo Alignment & Shell
   ═══════════════════════════════════════════════════════════════════ */

/* Align Bootstrap primary components with Indigo #4f46e5 */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
}

.list-group-item.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

/* Reusable Utilities */
.modal-glass {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
}

.btn-xs {
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    line-height: 1.35;
    border-radius: 0.375rem;
}

.bg-teal {
    background-color: #0d9488 !important;
}

/* Portal Sidebar Sticky Scroll & Active Icon Contrast */
@media (min-width: 992px) {
    .edu-sidebar {
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 104px);
        overflow-y: auto;
    }
}

.sidebar-section-header {
    letter-spacing: 0.05em;
}

.sidebar-list .list-group-item.active i {
    color: currentColor !important;
}

/* Prevent mobile sidebar FAB from overlapping bottom-left pagination/actions */
@media (max-width: 991.98px) {
    body {
        padding-bottom: 4.5rem;
    }
    body.auth-shell-bg,
    body.auth-shell-legal {
        padding-bottom: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 4 — Shared Auth Shell, Avatar Picker, Permission Switches & Exam Timer
   ═══════════════════════════════════════════════════════════════════ */

/* Shared standalone auth page background & glassmorphic container */
body.auth-shell-bg {
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 52%, #e2e8f0 100%);
    background-attachment: fixed;
}

.auth-glass {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.12);
    border-radius: 24px;
}

.auth-brand-badge {
    width: 70px;
    height: 70px;
}

.auth-pwd-toggle {
    border-color: var(--border-light);
    background-color: var(--surface);
    color: var(--text-muted);
    min-width: 48px;
    border-top-right-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.auth-pwd-toggle:hover,
.auth-pwd-toggle:focus-visible {
    background-color: rgba(79, 70, 229, 0.06);
    border-color: var(--primary);
    color: var(--primary);
}

.auth-pwd-toggle:focus-visible {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    z-index: 5;
}

.legal-doc-container {
    max-width: 820px;
}

/* Keyboard-accessible avatar picker tile across all 4 portal profile.php pages */
.avatar-picker-tile {
    display: block;
    width: 100%;
    cursor: pointer;
    border-radius: 14px;
    border: 2px solid var(--border-light);
    background-color: var(--bg-main);
    transition:
        border-color 0.18s ease,
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.avatar-picker-tile:hover {
    border-color: rgba(79, 70, 229, 0.45);
    background-color: rgba(79, 70, 229, 0.04);
    transform: translateY(-2px);
}

.avatar-picker-tile:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.25);
    outline: none;
}

.avatar-picker-tile:has(input:checked),
.avatar-picker-tile.is-selected {
    border-color: var(--primary);
    background-color: rgba(79, 70, 229, 0.08);
    box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.2);
}

/* Crisp oversized toggle switch for admin/permissions.php (replaces transform: scale) */
.permission-switch.form-check-input,
.permission-switch .form-check-input {
    width: 2.75rem;
    height: 1.4rem;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.permission-switch.form-check-input:checked,
.permission-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.permission-switch.form-check-input:focus,
.permission-switch .form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.2);
}

.permission-switch.form-check-input:disabled,
.permission-switch .form-check-input:disabled {
    cursor: not-allowed;
}

/* Subtle urgency pulse for student/take_quiz.php final-minute countdown */
.exam-timer-pulse {
    animation: eduExamTimerPulse 1.2s ease-in-out infinite;
}

@keyframes eduExamTimerPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
        transform: scale(1.03);
    }
}

@media (prefers-reduced-motion: reduce) {
    .exam-timer-pulse {
        animation: none;
    }
}
