@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
    /* Dark Theme (Default) - "Noor" palette: brand blue (from logo) + warm gold */
    --primary: #0B4F4A; /* Brand Dark Blue (from logo) */
    --primary-light: #12726B; /* Lighter shade for depth */
    --accent: #FF8A5C; /* Warm Gold for Dark Theme */
    --accent-nav: #FF8A5C; /* Same for nav */
    --accent-hover: #E5703F;
    --text-main: #F7F3E8;
    --text-muted: #9FCFC9;
    --card-bg: rgba(11, 79, 74, 0.7);
    --bg-color: #04201E; /* Very dark blue background */
    --success: #10B981;
    --danger: #EF4444;
    --glass-border: rgba(255, 255, 255, 0.12);
    --header-bg: var(--primary);
    --header-text: var(--text-main);
    --header-muted: var(--text-muted);
    /* Fixed brand blues — do NOT flip between themes (used by always-dark components like .spotlight-card) */
    --brand-blue: #0B4F4A;
    --brand-blue-light: #12726B;
}

body.light-theme {
    /* Light Theme */
    --primary: #FFFFFF;
    --primary-light: #E0F2EF;
    --accent: #D9531E; /* Brand Gold for Buttons */
    --accent-nav: #FF8A5C; /* Lighter Gold for Dark Headers */
    --accent-hover: #B84215;
    --text-main: #0B4F4A; /* Brand Dark Blue for text */
    --text-muted: #4F7F7A;
    --card-bg: rgba(255, 253, 246, 0.85);
    --bg-color: #EAF6F4; /* Soft light blue background */
    --success: #059669;
    --danger: #DC2626;
    --glass-border: rgba(11, 79, 74, 0.1);
    --header-bg: #0B4F4A; /* Keep header brand-colored even in light mode */
    --header-text: #F7F3E8;
    --header-muted: #9FCFC9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: pan-x pan-y;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Full-width app container */
.app-container {
    width: 100%;
    max-width: none;
    height: 100%;
    background-color: var(--primary);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* Typography & Layout Utilities */
h1, h2, h3, h4 {
    font-weight: 600;
}

p {
    line-height: 1.5;
}

.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(254, 65, 1, 0.3); /* Orange shadow */
    transition: all 0.3s ease;
}

.btn:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(254, 65, 1, 0.4);
}
.btn:active { transform: scale(0.98); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    box-shadow: none;
}
.btn-outline:hover {
    background: rgba(254, 65, 1, 0.1);
    box-shadow: none;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-family: 'Cairo', sans-serif;
    font-size: 1.4rem;
    color: var(--accent);
    letter-spacing: 0.3px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Badge "matière" dans l'en-tête : inline sur grand écran, sur sa propre ligne sur mobile */
.header-matiere { display: inline-block; }
@media (max-width: 600px) {
    .header-matiere {
        display: block;
        margin-left: 0 !important;
        margin-top: 4px;
        width: -moz-fit-content;
        width: fit-content;
        max-width: 100%;
    }
}

.logo-biseau {
    background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(226,232,240,0.5));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 3D Bevel effect: inner highlights and shadows, outer drop shadow */
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.9),
        inset -3px -3px 6px rgba(0, 0, 0, 0.1),
        3px 3px 10px rgba(0, 0, 0, 0.3),
        -1px -1px 3px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 3px;
    position: relative;
    z-index: 1;
}

.logo-biseau::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: -1;
    animation: orange-radiation 2s infinite;
}

@keyframes orange-radiation {
    0% {
        box-shadow: 0 0 0 0 rgba(254, 65, 1, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(254, 65, 1, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(254, 65, 1, 0);
    }
}

.logo-biseau::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.7) 25%, transparent 30%);
    background-size: 200% 200%;
    background-position: -150% 0;
    animation: glass-shine-bg 4s infinite;
    z-index: 3;
    pointer-events: none;
}

@keyframes glass-shine-bg {
    0% {
        background-position: -150% 0;
    }
    20% {
        background-position: 250% 0;
    }
    100% {
        background-position: 250% 0;
    }
}

.logo-biseau img {
    border-radius: 50%;
    object-fit: cover;
    z-index: 2;
    position: relative;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 8px rgba(254, 65, 1, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem 100px 1rem; /* Space for bottom nav */
}

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

/* Ligne d'en-tête d'un cours (espace prof)
   Thème sombre (défaut) : bleu sur or — Thème clair : or sur bleu (inverse) */
.course-header-row {
    background: linear-gradient(135deg, var(--accent-nav) 0%, var(--accent-hover) 100%);
}
.course-header-row .course-title,
.course-header-row .course-arrow {
    color: var(--brand-blue);
}
body.light-theme .course-header-row {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-light) 100%);
}
body.light-theme .course-header-row .course-title,
body.light-theme .course-header-row .course-arrow {
    color: var(--accent-nav);
}
/* Zone dépliée d'un cours : jaune clair en thème sombre, bleu clair en thème clair.
   Le panneau étant clair dans les deux cas, son contenu passe en texte bleu foncé. */
.course-content-panel {
    background: #F7EAC5;
}
body.light-theme .course-content-panel {
    background: #8FADD4;
}
.course-content-panel,
.course-content-panel h3,
.course-content-panel h4,
.course-content-panel p,
.course-content-panel label,
.course-content-panel strong {
    color: #0B4F4A;
}
.course-content-panel input,
.course-content-panel textarea,
.course-content-panel select {
    background: #ffffff !important;
    color: #0B4F4A !important;
    border: 1px solid rgba(11, 79, 74, 0.2) !important;
}
.course-content-panel input::placeholder,
.course-content-panel textarea::placeholder {
    color: rgba(11, 79, 74, 0.45) !important;
}
.course-content-panel .prof-concept-item {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(11, 79, 74, 0.12) !important;
}

/* Boutons d'action (renommer / supprimer) : pastille contrastée qui s'inverse
   avec le thème, pour que les icônes restent visibles sur or comme sur bleu */
.course-header-row .course-action-btn {
    background: rgba(11, 79, 74, 0.2);
    border: 1px solid rgba(11, 79, 74, 0.35);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.course-header-row .course-action-btn:hover {
    background: rgba(11, 79, 74, 0.38);
    transform: translateY(-1px);
}
body.light-theme .course-header-row .course-action-btn {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
}
body.light-theme .course-header-row .course-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Spotlight Card — deep green highlight card (e.g. "Today's Ayah" style) */
.spotlight-card {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-light) 100%);
    color: #F7F3E8;
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    position: relative;
    overflow: hidden;
}
.spotlight-card::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -15%;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,175,106,0.25) 0%, transparent 70%);
    pointer-events: none;
}
.spotlight-card h3 {
    margin: 0 0 0.4rem 0;
    font-size: 1.05rem;
    color: var(--accent-nav);
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
}
.spotlight-card p {
    margin: 0;
    font-size: 0.95rem;
    color: #F7F3E8;
    position: relative;
    z-index: 1;
}
.spotlight-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(212, 175, 106, 0.5);
    color: var(--accent-nav);
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 0.9rem;
    position: relative;
    z-index: 1;
}

/* Quick Access grid — icon tiles (Prayer / Habits / Umrah / Planner style) */
.section-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.9rem 0;
}
.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.quick-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 1.25rem 1rem;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.92rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.quick-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}
.quick-tile-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 106, 0.15);
    color: var(--accent);
}
.quick-tile-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
}

body.light-theme .form-control {
    background: rgba(255, 255, 255, 0.6);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(254, 65, 1, 0.15);
    background: rgba(255, 255, 255, 0.1);
}

body.light-theme .form-control:focus {
    background: #FFFFFF;
}

.form-control option {
    background-color: var(--primary); 
    color: var(--text-main); 
}

/* Bottom Navigation — light pill bar, consistent across themes (Noor style) */
.bottom-nav {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(250, 246, 236, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(30, 58, 47, 0.08);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    padding: 0.85rem 0 calc(0.85rem + env(safe-area-inset-bottom));
    z-index: 10;
}

.sidebar-logo {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #93A8C7;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    gap: 0.3rem;
}

.nav-item.active {
    color: #0B4F4A;
}
.nav-item.active svg {
    stroke-width: 3.0 !important;
    stroke: #0B4F4A !important;
}

.nav-item svg {
    width: 24px !important;
    height: 24px !important;
    fill: none !important;
    stroke: #93A8C7 !important;
    stroke-width: 2.4 !important;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease, stroke-width 0.2s ease, stroke 0.2s ease;
}

.logout-btn {
    background: rgba(255, 165, 115, 0.15); /* Soft orange background */
    color: var(--accent-nav) !important;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--accent-nav);
    color: white !important;
    transform: translateY(-2px);
}

/* EdTech Specific Components */
.sticky-cta-container {
    position: sticky;
    bottom: 70px; /* Just above bottom nav */
    padding: 1rem 0;
    background: linear-gradient(to top, var(--bg-color) 70%, transparent);
    z-index: 5;
    text-align: center;
}

.media-status {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.media-pill {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}
.media-pill.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.gamification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: var(--header-bg);
    color: var(--header-text);
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.video-container {
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    position: relative;
}

.horizontal-tabs {
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.horizontal-tabs::-webkit-scrollbar {
    height: 6px;
}
.horizontal-tabs::-webkit-scrollbar-track {
    background: transparent;
}
.horizontal-tabs::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}
.tab-item {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.tab-item:hover {
    background: #f1f5f9;
}
body.light-theme .tab-item {
    background: #1e3a8a;
    color: #ffffff;
}
body.light-theme .tab-item:hover {
    background: #172554;
}
.tab-item.active {
    background: var(--accent);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.circular-progress {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--success) 75%, var(--card-bg) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    position: relative;
}
.circular-progress::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-color);
}
.progress-value {
    position: relative;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.timeline {
    border-left: 2px solid var(--accent);
    margin-left: 1rem;
    padding-left: 1.5rem;
    position: relative;
}
.timeline-item {
    margin-bottom: 1.5rem;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.9rem;
    top: 0.2rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-color);
}

.btn-secondary {
    background: var(--primary-light);
    color: var(--text-main);
}
body.light-theme .btn-secondary {
    background: #0F172A; /* Primary Dark Blue for light theme actions */
    color: #FFFFFF;
}
.btn-neutral {
    background: var(--card-bg);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

.quiz-widget {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
}
.math-formula {
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* Custom Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-title {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    font-weight: bold;
}

.modal-content {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge.warning { background: rgba(249, 115, 22, 0.2); color: var(--accent); }

/* Lists */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--glass-border);
}
.list-item:last-child {
    border-bottom: none;
}

/* Theme Toggle Button */
.theme-toggle {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.1);
    color: #1e293b;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.app-header .theme-toggle {
    color: #1e293b;
}
.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}
body.light-theme .theme-toggle {
    background: #1e293b;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.1);
}
body.light-theme .theme-toggle:hover {
    background: #0f172a;
}

/* Quiz Generator Modal Controls */
.toggle-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    text-align: center;
}
.toggle-btn:hover {
    background: var(--glass-border);
}
.toggle-btn.active {
    background: rgba(217, 83, 30, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* Generator modal header — fixed brand blue, consistent in both themes */
.modal-gen-header {
    padding: 1.6rem 1.8rem 1.2rem;
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-light) 100%);
    border-radius: 20px 20px 0 0;
}
.modal-gen-header .icon-badge {
    width: 36px; height: 36px; background: rgba(255,255,255,0.18); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
}
.modal-gen-header h3 { margin: 0; color: #F7F3E8; font-size: 1.15rem; font-weight: 700; }
.modal-gen-header p { color: rgba(247,243,232,0.8); font-size: 0.85rem; margin: 0.3rem 0 0; }

.modal-gen-body {
    background: var(--card-bg);
}
.modal-gen-footer {
    padding: 1rem 1.8rem;
    background: var(--card-bg);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 0.8rem;
    border-radius: 0 0 20px 20px;
}
.btn-cancel {
    flex: 1; padding: 0.75rem; border: 1.5px solid var(--glass-border); background: transparent;
    color: var(--text-muted); border-radius: 12px; font-size: 0.95rem; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: background 0.2s;
}
.btn-cancel:hover { background: var(--glass-border); }
.btn-confirm {
    flex: 1; padding: 0.75rem; border: none; color: #fff; border-radius: 12px;
    font-size: 0.95rem; font-weight: 600; font-family: inherit; cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 4px 12px rgba(217, 83, 30,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(217, 83, 30,0.4); }
.modal-gen-input {
    width: 100%; box-sizing: border-box; padding: 0.75rem 1rem; border: 1.5px solid var(--glass-border);
    border-radius: 12px; font-size: 0.95rem; font-family: inherit; background: var(--bg-color);
    color: var(--text-main); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-gen-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 83, 30,0.15); }
.modal-gen-label {
    display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em;
}
/* Bouton flottant générique (ajouter un cours, un paiement, ...) */
.fab-add-course {
    position: fixed; bottom: 90px; right: 20px; z-index: 9990;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.35);
}
@media (min-width: 768px) {
    .fab-add-course { bottom: 20px; }
}
.btn-primary-gradient {
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    font-weight: 700;
    border: none;
}
.btn-primary-gradient:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ==========================================================================
   Responsive Layout (Desktop & Large Screens)
   ========================================================================== */
@media (min-width: 768px) {
    /* For dashboard pages with bottom-nav */
    .app-container.with-sidebar {
        max-width: none;
        width: 100vw;
        border-radius: 0;
        display: grid;
        /* 240px = largeur réelle de la sidebar fixe (.bottom-nav). L'en-tête reste flush contre la
           sidebar (comme avant) ; l'espace visible n'est ajouté que dans .app-content ci-dessous. */
        grid-template-columns: 240px 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "sidebar header"
            "sidebar content";
        overflow: hidden;
    }

    /* For login page without bottom-nav */
    .app-container:not(.with-sidebar) {
        max-width: none;
        width: 100vw;
        border-radius: 0;
    }

    /* Assign grid areas */
    .app-header, .gamification-header {
        grid-area: header;
        z-index: 10;
    }

    .app-content {
        grid-area: content;
        padding-bottom: 1.5rem; /* Remove mobile bottom nav space */
        padding-left: 20px; /* Espace visible entre la sidebar et le contenu (l'en-tête reste flush) */
        overflow-y: auto;
        box-sizing: border-box;
    }

    /* Hide original logos in the top header on desktop */
    .app-header .logo-biseau,
    .gamification-header .logo-biseau {
        display: none !important;
    }

    /* Transform Bottom Nav into Sidebar */
    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 240px; /* Slightly wider sidebar for better breathing room */
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 2.5rem 1.25rem;
        border-top: none;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 0; /* Écrase les coins arrondis hérités du style mobile (bottom-sheet) */
        background: rgba(4, 32, 30, 0.98) !important; /* Rich Dark Blue (#04201E) */
        backdrop-filter: blur(16px);
        gap: 0.5rem;
        z-index: 9999;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    }

    /* Show Sidebar Logo on Desktop */
    .sidebar-logo {
        display: flex;
        justify-content: center;
        margin-bottom: 2.5rem;
    }
    
    .sidebar-logo .logo-biseau {
        width: 100px !important;
        height: 100px !important;
        border-radius: 50% !important;
        background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(226,232,240,0.5)) !important;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 
            inset 2px 2px 4px rgba(255, 255, 255, 0.9),
            inset -3px -3px 6px rgba(0, 0, 0, 0.1),
            3px 3px 10px rgba(0, 0, 0, 0.3),
            -1px -1px 3px rgba(255, 255, 255, 0.1) !important;
    }
    
    .sidebar-logo img {
        width: 80px !important;
        height: 80px !important;
        border-radius: 50% !important;
    }

    /* Adjust nav items for sidebar */
    .nav-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0.85rem 1.25rem !important;
        border-radius: 12px !important;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
        margin-bottom: 0.35rem !important;
        font-size: 1.1rem !important;
        font-weight: 500 !important;
        color: var(--accent-nav) !important; /* Orange text as in mobile */
        border: 1px solid transparent !important;
        text-decoration: none !important;
    }

    /* Hover State */
    .nav-item:hover {
        background: rgba(255, 255, 255, 0.04) !important;
        color: #f8fafc !important;
    }

    /* Active State */
    .nav-item.active {
        background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(239, 68, 68, 0.15)) !important;
        border: 1px solid rgba(249, 115, 22, 0.3) !important;
        color: #ffedd5 !important; /* Coral active tint */
    }

    /* SVGs inside nav items */
    .nav-item svg {
        margin-right: 1rem !important;
        width: 24px !important; /* Unified 24px container size */
        height: 24px !important;
        flex-shrink: 0 !important; /* CRITICAL: Prevent text squeeze */
        stroke: currentColor !important; /* Inherits active/hover/normal text colors automatically */
        fill: none !important;
        stroke-width: 2.2 !important;
        stroke-linecap: round !important;
        stroke-linejoin: round !important;
        transition: stroke-width 0.2s ease, transform 0.2s ease !important;
    }
    
    .nav-item.active svg {
        stroke-width: 2.5 !important;
    }

    /* Logout Button Styling */
    .logout-btn {
        margin-top: auto !important;
        margin-bottom: 1rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: 50px !important;
        height: 50px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(239, 68, 68, 0.08) !important;
        border: 1px solid rgba(239, 68, 68, 0.2) !important;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    .logout-btn svg {
        margin-right: 0 !important;
        width: 22px !important;
        height: 22px !important;
        stroke: #ef4444 !important;
    }
    
    .logout-btn:hover {
        background: rgba(239, 68, 68, 0.2) !important;
        border-color: rgba(239, 68, 68, 0.4) !important;
        transform: scale(1.06) rotate(-5deg);
        box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25) !important;
    }
}

/* ============================================================
   Sélecteur de langue (FR / ع) — voir includes/i18n.php
   ============================================================ */
.lang-switcher {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    display: flex;
    gap: 2px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.lang-switcher .lang-opt {
    min-width: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.lang-switcher .lang-opt:hover { color: var(--text-main); }
.lang-switcher .lang-opt.active {
    background: var(--accent);
    color: #fff;
}
/* Variante « en ligne » du sélecteur (en-tête Espace Professeur) */
.lang-switcher--inline {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    box-shadow: none;
}

/* En-tête applicatif : éviter que les boutons (dont le sélecteur de langue)
   ne se compressent sur petit écran — on autorise le passage à la ligne. */
@media (max-width: 640px) {
    .app-header {
        flex-wrap: wrap;
        row-gap: 10px;
    }
}
.prof-lang-toggle span { line-height: 1; }
.prof-lang-toggle:hover { filter: brightness(1.05); }

/* ==========================================================================
   Menu du bas (mobile, tous les comptes) : textes en bleu sombre, orange sombre quand l'entrée est active / a le focus
   ========================================================================== */
@media (max-width: 767.98px) {
    .bottom-nav .nav-item,
    .bottom-nav .nav-item:visited {
        color: #0B2A5B;
    }
    .bottom-nav .nav-item svg {
        stroke: #0B2A5B !important;
    }
    .bottom-nav .nav-item:hover,
    .bottom-nav .nav-item:focus,
    .bottom-nav .nav-item:focus-visible,
    .bottom-nav .nav-item:active,
    .bottom-nav .nav-item.active {
        color: #C2410C;
        outline: none;
    }
    .bottom-nav .nav-item:hover svg,
    .bottom-nav .nav-item:focus svg,
    .bottom-nav .nav-item:focus-visible svg,
    .bottom-nav .nav-item:active svg,
    .bottom-nav .nav-item.active svg {
        stroke: #C2410C !important;
    }
}

/* ==========================================================================
   En-tête élève (XP / Jours / Badges / Parfaits) : couleurs plus claires et plus contrastées sur le fond bleu marine,
   texte plus gras et plus grand, légère pastille pour les séparer visuellement.
   ========================================================================== */
.gamification-header #global-xp,
.gamification-header #global-jours,
.gamification-header #global-badges-dispo,
.gamification-header #global-badges {
    font-weight: 800 !important;
    font-size: 0.98rem !important;
    letter-spacing: 0.01em;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    white-space: nowrap;
}
.gamification-header #global-xp {
    color: #FFD866 !important;          /* or vif */
    background: rgba(255, 216, 102, 0.14);
}
.gamification-header #global-jours {
    color: #FFB24D !important;          /* orange clair */
    background: rgba(255, 178, 77, 0.15);
}
.gamification-header #global-badges-dispo {
    color: #D0C4FF !important;          /* violet clair */
    background: rgba(208, 196, 255, 0.15);
}
.gamification-header #global-badges {
    color: #7CF0C0 !important;          /* vert menthe */
    background: rgba(124, 240, 192, 0.15);
}
@media (max-width: 640px) {
    .gamification-header #global-xp,
    .gamification-header #global-jours,
    .gamification-header #global-badges-dispo,
    .gamification-header #global-badges {
        font-size: 0.9rem !important;
        padding: 0.18rem 0.5rem;
    }
}

/* En-tête élève défilable horizontalement (XP / Jours / Badges / Parfaits / boutons) quand l'écran est trop étroit */
.gamification-header {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;            /* Firefox */
    gap: 0.75rem;
}
.gamification-header::-webkit-scrollbar { display: none; }   /* Chrome / Safari */
.gamification-header > * {
    flex: 0 0 auto;                   /* chaque bloc garde sa taille : c'est l'en-tête qui défile */
}
.gamification-header > div:last-child {
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding-inline-end: 0.25rem;
}
.gamification-header #global-xp,
.gamification-header #global-jours,
.gamification-header #global-badges-dispo,
.gamification-header #global-badges,
.gamification-header .theme-toggle,
.gamification-header button {
    flex: 0 0 auto;
}

/* Aperçu élève (espace professeur) : pastille « Quitter l'aperçu » dans l'en-tête */
.apercu-pill { flex: none; padding: .35rem .8rem; border-radius: 999px; font-size: .78rem; font-weight: 800; text-decoration: none; white-space: nowrap;
    background: #F26B1D; color: #fff; border: 1px solid rgba(255,255,255,.35); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.apercu-pill:hover { filter: brightness(1.08); }

/* Vue élève du professeur : choix de la matière / de la filière dans l'en-tête */
.apercu-form { display: inline-flex; align-items: center; gap: .45rem; flex: none; margin: 0; }
.apercu-form .apercu-label { font-size: .78rem; font-weight: 800; color: #FFD866; white-space: nowrap; }
.apercu-form select { max-width: 210px; padding: .32rem .55rem; border-radius: 10px; border: 1px solid rgba(255,255,255,.35);
    background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: .8rem; font-weight: 700; }
.apercu-form select option { color: #0B4F4A; background: #fff; }


/* ==========================================================================
   Menu ÉLÈVE : mêmes pastilles d'icône que les tuiles « Accès rapide » du tableau de bord
   (carré arrondi teinté, trait doré 2 px). L'entrée active passe en doré plein, icône blanche.
   Réservé aux pages élève (<nav class="bottom-nav eleve-nav">) : les autres menus ne changent pas.
   ========================================================================== */
.bottom-nav.eleve-nav .nav-item:not(.logout-btn) svg {
    box-sizing: border-box;
    width: 40px !important;
    height: 40px !important;
    padding: 8px;
    border-radius: 14px;
    background: rgba(212, 175, 106, 0.15);
    stroke: var(--accent) !important;
    stroke-width: 2 !important;
    transition: background .2s ease, stroke .2s ease, transform .2s ease;
}
.bottom-nav.eleve-nav .nav-item:not(.logout-btn):hover svg {
    background: rgba(212, 175, 106, 0.28);
    transform: translateY(-2px);
}
.bottom-nav.eleve-nav .nav-item.active:not(.logout-btn) svg {
    background: var(--accent);
    stroke: #fff !important;
    stroke-width: 2.2 !important;
    box-shadow: 0 6px 14px rgba(217, 83, 30, 0.35);
}
@media (max-width: 767.98px) {
    .bottom-nav.eleve-nav { padding-top: 0.55rem; padding-bottom: calc(0.55rem + env(safe-area-inset-bottom)); }
    .bottom-nav.eleve-nav .nav-item:not(.logout-btn) svg { width: 38px !important; height: 38px !important; padding: 7px; }
    .bottom-nav.eleve-nav .nav-item { gap: 0.2rem; }
}
@media (min-width: 768px) {
    /* barre latérale : l'entrée active garde son fond doux, la pastille d'icône porte le doré */
    .bottom-nav.eleve-nav .nav-item.active:not(.logout-btn) {
        background: rgba(212, 175, 106, 0.10) !important;
        border-color: rgba(212, 175, 106, 0.35) !important;
        color: #fff !important;
    }
    .bottom-nav.eleve-nav .nav-item:not(.logout-btn) svg { margin-right: .85rem !important; }
}


/* ==========================================================================
   Tableau de bord élève : analyses (indicateurs + graphiques sans bibliothèque externe)
   ========================================================================== */
.an-wrap { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.an-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.an-kpi { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 16px; padding: .85rem .5rem;
          display: flex; flex-direction: column; align-items: center; gap: .15rem; text-align: center; }
.an-kpi b { font-size: 1.45rem; line-height: 1.1; color: var(--text-main); }
.an-kpi span { font-size: .74rem; color: var(--text-muted); font-weight: 600; }
.an-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.an-card { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 18px; padding: 1rem 1.1rem; min-width: 0; }
.an-card h4 { margin: 0 0 .8rem 0; font-size: .98rem; color: var(--text-main); }
.an-wide { grid-column: 1 / -1; }
.an-empty { text-align: center; color: var(--text-muted); font-weight: 600; }
.an-hint { margin: -.4rem 0 .7rem; font-size: .78rem; color: var(--text-muted); }
.an-none { margin: 0; color: var(--text-muted); font-size: .88rem; }
.an-more { align-self: flex-start; font-weight: 700; font-size: .88rem; color: var(--accent); text-decoration: none; }
.an-more:hover { text-decoration: underline; }
/* barres verticales : 7 jours */
.an-bars { display: flex; align-items: flex-end; gap: .45rem; height: 150px; }
.an-bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.an-bar { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--accent), #8A3510); }
.an-bar-val { font-size: .72rem; font-weight: 800; color: var(--text-main); min-height: 1em; }
.an-bar-lab { font-size: .66rem; color: var(--text-muted); white-space: nowrap; }
/* anneau */
.an-donut-row { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.an-donut { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; flex: none; position: relative; }
.an-donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--bg-color, #fff); }
.an-donut span { position: relative; z-index: 1; font-weight: 800; font-size: 1.15rem; color: var(--text-main); }
.an-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; font-size: .82rem; color: var(--text-main); }
.an-legend li { display: flex; align-items: center; gap: .45rem; }
.an-legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.an-legend b { margin-inline-start: auto; padding-inline-start: .6rem; }
/* barres horizontales */
.an-hrow { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; align-items: center; gap: .6rem; margin-bottom: .55rem; font-size: .84rem; color: var(--text-main); }
.an-hrow:last-child { margin-bottom: 0; }
.an-hlab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.an-hlab-wide { white-space: normal; }
.an-hrow b { min-width: 2.6em; text-align: end; }
.an-htrack { height: 10px; border-radius: 999px; background: rgba(120, 130, 150, .18); overflow: hidden; }
.an-htrack span { display: block; height: 100%; border-radius: 999px; }
@media (max-width: 640px) {
    .an-grid { grid-template-columns: 1fr; }
    .an-kpis { gap: .5rem; }
    .an-kpi b { font-size: 1.2rem; }
    .an-hrow { grid-template-columns: minmax(64px, 38%) 1fr auto; }
}


/* Analyses détaillées (page Statistiques élève) : compléments des styles .an-* du tableau de bord */
.an-kpis-6 { grid-template-columns: repeat(6, 1fr); }
.an-line { display: grid; grid-template-columns: auto 1fr; gap: .5rem; align-items: stretch; }
.an-line-y { display: flex; flex-direction: column; justify-content: space-between; font-size: .66rem; color: var(--text-muted); text-align: end; padding: 0 0 0 .1rem; }
.an-line svg { width: 100%; height: 160px; display: block; overflow: visible; }
.an-line svg .g { stroke: rgba(120, 130, 150, .28); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.an-line svg .area { fill: rgba(217, 83, 30, .16); }
.an-line svg .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.an-line-plot { position: relative; }
.an-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-color, #fff); box-sizing: border-box; }
.an-line-x { display: flex; justify-content: space-between; margin-top: .4rem; font-size: .7rem; color: var(--text-muted); }
.an-bars-thin { height: 110px; gap: 2px; }
.an-bars-thin .an-bar { max-width: none; border-radius: 3px 3px 1px 1px; }
.an-heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.an-heat-h { font-size: .64rem; text-align: center; color: var(--text-muted); font-weight: 700; }
.an-heat-c { aspect-ratio: 1 / 1; border-radius: 6px; background: rgba(120, 130, 150, .14); }
.an-heat-future { background: transparent; border: 1px dashed rgba(120, 130, 150, .25); }
.an-hrow small { color: var(--text-muted); font-weight: 600; }
@media (max-width: 640px) {
    .an-kpis-6 { grid-template-columns: repeat(3, 1fr); }
}
