/* ── Variables ── */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --font-size-base: 15px;
}

/* ── Base ── */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    font-size: var(--font-size-base);
    transition: background 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Navbar ── */
.navbar {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%) !important;
    padding: 0.65rem 0;
    box-shadow: 0 2px 16px rgba(37,99,235,0.3);
}

.navbar-brand {
    font-size: 1.3rem;
    letter-spacing: -0.3px;
    font-weight: 800;
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.navbar-nav .nav-link:hover {
    background: rgba(255,255,255,0.15);
}

.btn-light.nav-register {
    font-weight: 600;
    color: var(--primary);
    border-radius: 20px;
    padding: 0.4rem 1.2rem;
}

/* ── Avatar chip ── */
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    border: 2px solid rgba(255,255,255,0.4);
}

/* ── Skip to content ── */
.skip-link {
    position: absolute;
    top: -999px;
    left: 0;
    z-index: 9999;
    padding: 8px 16px;
    background: #1d4ed8;
    color: white;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}
.skip-link:focus { top: 0; color: white; }

/* ── Flash ── */
.container > .alert {
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
}

/* ── Hero ── */
.hero-section {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 45%, #3b82f6 100%);
    color: white;
    padding: 80px 0 70px;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
}

.hero-section .lead {
    font-size: 1.15rem;
    opacity: 0.88;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(4px);
}

/* ── Feature icon ── */
.feature-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1.25rem;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ── Course card ── */
.course-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden;
    background: var(--card-bg);
}

.course-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(37,99,235,0.2);
}

.course-card-header {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.course-card-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.18));
    pointer-events: none;
}

.course-color-0 .course-card-header { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.course-color-1 .course-card-header { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.course-color-2 .course-card-header { background: linear-gradient(135deg, #0891b2, #0e7490); }
.course-color-3 .course-card-header { background: linear-gradient(135deg, #d97706, #b45309); }
.course-color-4 .course-card-header { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.course-color-5 .course-card-header { background: linear-gradient(135deg, #16a34a, #15803d); }

.course-color-0 { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.course-color-1 { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.course-color-2 { background: linear-gradient(135deg, #0891b2, #0e7490); }
.course-color-3 { background: linear-gradient(135deg, #d97706, #b45309); }
.course-color-4 { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.course-color-5 { background: linear-gradient(135deg, #16a34a, #15803d); }

.course-card-header .card-icon {
    width: 60px; height: 60px;
    border-radius: 18px;
    background: rgba(255,255,255,0.22);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: white;
    border: 2px solid rgba(255,255,255,0.35);
    position: relative; z-index: 1;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* ── Stat card ── */
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 2px;
    letter-spacing: -1px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ── Sidebar/content cards ── */
.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

/* ── Lesson list item ── */
.lesson-item {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.18s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    padding: 12px 16px;
    margin-bottom: 6px;
    background: var(--card-bg);
    position: relative;
    overflow: hidden;
}
.lesson-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.15s;
    border-radius: 0 2px 2px 0;
}
.lesson-item:hover::before, .lesson-item.active::before { opacity: 1; }
.lesson-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(4px);
}
.lesson-item.completed {
    background: #f0fdf4;
    border-color: #86efac;
}
.lesson-item.completed::before { background: #16a34a; opacity: 1; }
.lesson-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* ── Lesson content ── */
.lesson-content {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text);
}
.lesson-content h2, .lesson-content h3, .lesson-content h4 {
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}
.lesson-content p { margin-bottom: 1rem; }
.lesson-content ul, .lesson-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.lesson-content li { margin-bottom: 0.4rem; }

.lesson-content pre {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 1.2rem 1.5rem;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.7;
    box-shadow: var(--shadow);
}
.lesson-content code {
    background: #f1f5f9;
    color: #dc2626;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.88em;
    border: 1px solid #e2e8f0;
}
.lesson-content pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
    border: none;
}
.lesson-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 0.75rem 1.25rem;
    background: var(--primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 1rem 0;
    color: #1e40af;
}

/* ── Video ── */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    background: #000;
    box-shadow: var(--shadow-lg);
}
.video-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* ── Quiz ── */
.quiz-question {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.quiz-option {
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    padding: 11px 16px;
    transition: all 0.15s;
    margin-bottom: 8px;
    user-select: none;
    background: var(--card-bg);
    color: var(--text);
}
.quiz-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.quiz-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ── Progress bar ── */
.progress {
    border-radius: 10px;
    background: #e2e8f0;
    overflow: hidden;
}
.progress-bar {
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

/* ── Auth ── */
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem !important;
}
.auth-card .form-control {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--card-bg);
    color: var(--text);
}
.auth-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ── Profile ── */
.profile-avatar {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(37,99,235,0.25);
    letter-spacing: -1px;
}

/* ── Admin ── */
.admin-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}
.admin-table td { color: var(--text); border-color: var(--border); }

.badge { border-radius: 20px; font-weight: 600; font-size: 0.75rem; }

/* ── Type badges ── */
.type-badge-text  { background: #dbeafe; color: #1d4ed8; }
.type-badge-video { background: #fee2e2; color: #b91c1c; }
.type-badge-quiz  { background: #fef9c3; color: #92400e; }

/* ── Difficulty badges ── */
.difficulty-badge {
    position: absolute;
    bottom: 8px; right: 8px;
    font-size: .7rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 1;
}
.difficulty-beginner     { background: rgba(22,163,74,.85);  color: #fff; }
.difficulty-intermediate { background: rgba(217,119,6,.85);  color: #fff; }
.difficulty-advanced     { background: rgba(220,38,38,.85);  color: #fff; }

/* ── Catalog filters ── */
.catalog-filters {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.catalog-sort-select {
    background-color: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}

/* ── Footer ── */
footer {
    background: #0f172a !important;
    margin-top: auto;
    border-top: 1px solid #1e293b;
}
footer .text-muted { color: rgba(255,255,255,0.55) !important; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: 0.85rem; }
.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* ── Search ── */
.search-wrapper { position: relative; }
.search-wrapper .form-control {
    padding-left: 2.8rem;
    border-radius: 25px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    height: 46px;
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrapper .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.search-wrapper .search-icon {
    position: absolute;
    left: 1rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Section titles ── */
.section-title {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* ── Empty state ── */
.empty-state { padding: 3rem 1rem; text-align: center; }
.empty-state i { font-size: 3.5rem; opacity: 0.25; margin-bottom: 1rem; }

/* ── Focus rings ── */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}
button:focus-visible, a:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

/* ── Form controls ── */
.form-control, .form-select {
    background: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}
.form-control:focus, .form-select:focus {
    background: var(--card-bg);
    color: var(--text);
}
.input-group-text {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-muted);
}

/* ── Animations ── */
.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════
   DARK THEME
   ════════════════════════════════════════ */
[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary-light: #172554;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

[data-theme="dark"] .progress { background: #334155; }

[data-theme="dark"] .lesson-item.completed {
    background: #14532d33;
    border-color: #166534;
}
[data-theme="dark"] .lesson-item.completed::before { background: #22c55e; }

[data-theme="dark"] .lesson-item:hover,
[data-theme="dark"] .lesson-item.active {
    color: #93c5fd;
    background: #172554;
    border-color: #3b82f6;
}

[data-theme="dark"] .type-badge-text  { background: #172554; color: #93c5fd; }
[data-theme="dark"] .type-badge-video { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .type-badge-quiz  { background: #451a03; color: #fde68a; }
[data-theme="dark"] .catalog-filters  { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .catalog-sort-select { background-color: var(--card-bg); color: var(--text); border-color: var(--border); }

[data-theme="dark"] .lesson-content code {
    background: #0f172a;
    color: #f87171;
    border-color: #334155;
}
[data-theme="dark"] .lesson-content blockquote {
    background: #172554;
    color: #93c5fd;
}
[data-theme="dark"] .quiz-option:hover,
[data-theme="dark"] .quiz-option.selected {
    background: #172554;
    border-color: #3b82f6;
}
[data-theme="dark"] .dropdown-menu { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .dropdown-item { color: #e2e8f0; }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .dropdown-divider { border-color: #334155; }

[data-theme="dark"] .table {
    color: #e2e8f0;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #253347;
    --bs-table-hover-bg: #253347;
}
[data-theme="dark"] .table thead th { border-bottom-color: #334155; }
[data-theme="dark"] .table td,
[data-theme="dark"] .table tr,
[data-theme="dark"] .table tbody tr { border-color: #334155; }

[data-theme="dark"] footer { background: #020617 !important; }

[data-theme="dark"] .alert-info    { background: #172554;    border-color: #1e40af; color: #bfdbfe; }
[data-theme="dark"] .alert-success { background: #14532d33; border-color: #166534; color: #bbf7d0; }
[data-theme="dark"] .alert-warning { background: #451a0333; border-color: #78350f; color: #fde68a; }
[data-theme="dark"] .alert-danger  { background: #450a0a33; border-color: #7f1d1d; color: #fecaca; }

[data-theme="dark"] .breadcrumb-item a { color: #93c5fd; }
[data-theme="dark"] .breadcrumb-item.active { color: #94a3b8; }
[data-theme="dark"] .bg-light { background: #253347 !important; }
[data-theme="dark"] .text-dark { color: #e2e8f0 !important; }
[data-theme="dark"] .border-bottom { border-color: #334155 !important; }
[data-theme="dark"] .border { border-color: #334155 !important; }
[data-theme="dark"] .section-title { color: #e2e8f0; }

[data-theme="dark"] section[style*="background: white"],
[data-theme="dark"] section[style*="background:white"] {
    background: var(--card-bg) !important;
    border-color: #334155 !important;
}
[data-theme="dark"] section[style*="background: linear-gradient(135deg, #eff6ff"] {
    background: linear-gradient(135deg, #0f172a, #172554) !important;
}
[data-theme="dark"] .fw-semibold.text-dark { color: #e2e8f0 !important; }

[data-theme="dark"] .text-muted    { color: #94a3b8 !important; }
[data-theme="dark"] .text-secondary { color: #94a3b8 !important; }
[data-theme="dark"] .badge.bg-light { background: #334155 !important; color: #cbd5e1 !important; }
[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] .form-select::placeholder { color: #64748b; }
[data-theme="dark"] .btn-outline-secondary { color: #94a3b8; border-color: #475569; }
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:focus { background: #334155; color: #e2e8f0; border-color: #475569; }
[data-theme="dark"] small, [data-theme="dark"] .small { color: inherit; }

[data-theme="dark"] .ai-generate-panel {
    background: linear-gradient(135deg, #2e1065, #1e1b4b) !important;
    border-color: #7c3aed !important;
}

/* ════════════════════════════════════════
   ACCESSIBILITY — FONT SIZES
   ════════════════════════════════════════ */
[data-fontsize="lg"] { --font-size-base: 18px; }
[data-fontsize="xl"] { --font-size-base: 21px; }
[data-fontsize="lg"] .hero-section h1 { font-size: 2.5rem; }
[data-fontsize="xl"] .hero-section h1 { font-size: 2.2rem; }
[data-fontsize="lg"] .stat-card .stat-value { font-size: 1.6rem; }
[data-fontsize="xl"] .stat-card .stat-value { font-size: 1.4rem; }

/* ════════════════════════════════════════
   ACCESSIBILITY — HIGH CONTRAST
   ════════════════════════════════════════ */
[data-contrast="on"] {
    --primary: #0000cc;
    --primary-dark: #00009a;
    --primary-light: #e0e8ff;
    --bg: #ffffff;
    --card-bg: #ffffff;
    --text: #000000;
    --text-muted: #333333;
    --border: #000000;
}
[data-theme="dark"][data-contrast="on"] {
    --bg: #000000;
    --card-bg: #111111;
    --text: #ffffff;
    --text-muted: #cccccc;
    --border: #ffffff;
    --primary: #66aaff;
    --primary-light: #001133;
}
[data-contrast="on"] .navbar { background: #000080 !important; border-bottom: 2px solid #ffffff; }
[data-contrast="on"] a { text-decoration: underline !important; }
[data-contrast="on"] .btn { border: 2px solid currentColor !important; font-weight: 700 !important; }
[data-contrast="on"] .badge { border: 1.5px solid currentColor !important; }
[data-contrast="on"] .type-badge-text  { background: #e0e8ff; color: #000080; }
[data-contrast="on"] .type-badge-video { background: #ffe0e0; color: #800000; }
[data-contrast="on"] .type-badge-quiz  { background: #fff8e0; color: #806000; }

/* ════════════════════════════════════════
   ACCESSIBILITY — NO ANIMATIONS
   ════════════════════════════════════════ */
[data-noanim="on"] *,
[data-noanim="on"] *::before,
[data-noanim="on"] *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
}

/* ════════════════════════════════════════
   ACCESSIBILITY TOOLBAR
   ════════════════════════════════════════ */
.access-fab {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 1050;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 20px rgba(37,99,235,0.45);
    transition: transform 0.2s, box-shadow 0.2s;
}
.access-fab:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(37,99,235,0.6); }
.access-fab:focus-visible { outline: 3px solid #f59e0b; outline-offset: 3px; }

.access-panel {
    position: fixed;
    bottom: 86px; right: 24px;
    z-index: 1049;
    width: 280px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: none;
    overflow: hidden;
}
.access-panel.open { display: block; animation: fadeIn 0.2s ease; }

.access-panel-header {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: white;
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
}
.access-panel-body { padding: 12px 16px; max-height: 70vh; overflow-y: auto; }
.access-section { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.access-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.access-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.access-row { display: flex; gap: 6px; flex-wrap: wrap; }
.access-btn {
    flex: 1;
    min-width: 60px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.access-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.access-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.access-btn-reset { width: 100%; background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.access-btn-reset:hover { background: #fca5a5; border-color: #dc2626; color: #7f1d1d; }

/* ════════════════════════════════════════
   LANGUAGE BADGE
   ════════════════════════════════════════ */
.lang-btn {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1.5px solid rgba(255,255,255,0.4);
    color: white;
    background: rgba(255,255,255,0.12);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    letter-spacing: 0.5px;
}
.lang-btn:hover, .lang-btn.active { background: rgba(255,255,255,0.28); color: white; text-decoration: none; }
.lang-btn.active { background: rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.7); }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 991px) {
    .access-panel { right: 16px; width: 260px; bottom: 80px; }
    .access-fab { right: 16px; bottom: 16px; }
}

@media (max-width: 768px) {
    .hero-section h1 { font-size: 2.1rem; }
    .hero-section { padding: 55px 0 45px; }
    .hero-section .lead { font-size: 1rem; }
    .section-title { font-size: 1.3rem; }
    .stat-card { padding: 1rem; gap: 0.75rem; }
    .stat-card .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .panel { padding: 1rem; }
    .profile-avatar { width: 64px; height: 64px; font-size: 1.5rem; }
    .course-card-header { height: 120px; }
    .lesson-item { padding: 10px 12px; }
    .auth-card { padding: 1.5rem !important; }
    .admin-table { font-size: 0.85rem; }
    .access-panel { width: calc(100vw - 32px); right: 16px; }
}

@media (max-width: 576px) {
    .hero-section { padding: 40px 0 35px; }
    .hero-section h1 { font-size: 1.8rem; }
    .d-flex.gap-2.flex-nowrap { flex-wrap: wrap !important; }
    .btn-lg { padding: 0.6rem 1.4rem; font-size: 0.95rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .navbar-brand { font-size: 1.1rem; }
    .section-title { font-size: 1.2rem; }
}

/* ════════════════════════════════════════
   AI FEATURES
   ════════════════════════════════════════ */
.btn-purple {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff; border: none; font-weight: 600;
}
.btn-purple:hover { background: linear-gradient(135deg, #6d28d9, #8b5cf6); color: #fff; }
.text-purple { color: #7c3aed; }

.ai-generate-panel {
    border: 2px dashed #a78bfa !important;
    background: linear-gradient(135deg, #faf5ff, #f5f3ff) !important;
}
.ai-gen-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.2rem; flex-shrink: 0;
}

.ai-chat-widget { position: fixed; bottom: 88px; right: 20px; z-index: 1040; }
.ai-chat-fab {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    border: none; color: white;
    font-size: 1.3rem; cursor: pointer;
    box-shadow: 0 4px 20px rgba(124,58,237,.45);
    display: flex; align-items: center; justify-content: center;
    transition: transform .2s, box-shadow .2s;
}
.ai-chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(124,58,237,.55); }

.ai-chat-panel {
    position: absolute;
    bottom: 64px; right: 0;
    width: 340px; max-height: 480px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex; flex-direction: column;
    opacity: 0; transform: translateY(16px) scale(.96);
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.ai-chat-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.ai-chat-header {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: white; padding: .75rem 1rem;
    border-radius: 18px 18px 0 0;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.ai-chat-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
}
.ai-chat-messages {
    flex: 1; overflow-y: auto; padding: .875rem;
    display: flex; flex-direction: column; gap: 8px;
}
.ai-message  { display: flex; justify-content: flex-start; }
.user-message { display: flex; justify-content: flex-end; }
.ai-bubble {
    background: var(--primary-light); color: var(--text);
    border-radius: 14px 14px 14px 3px;
    padding: 8px 12px; font-size: .875rem; line-height: 1.55;
    max-width: 88%; white-space: pre-wrap; word-break: break-word;
}
.user-bubble {
    background: var(--primary); color: #fff;
    border-radius: 14px 14px 3px 14px;
    padding: 8px 12px; font-size: .875rem; line-height: 1.55;
    max-width: 88%; word-break: break-word;
}
.ai-chat-typing {
    display: flex; gap: 4px; padding: 10px 14px;
    background: var(--primary-light);
    border-radius: 14px 14px 14px 3px;
    align-items: center;
}
.ai-chat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--primary);
    animation: ai-dot 1.4s ease-in-out infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: .2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-dot {
    0%, 80%, 100% { transform: scale(.6); opacity: .4; }
    40%            { transform: scale(1);  opacity: 1;  }
}
.ai-chat-input {
    display: flex; gap: 8px; padding: .75rem;
    border-top: 1px solid var(--border); flex-shrink: 0;
}
.ai-chat-input input {
    flex: 1; border: 1px solid var(--border); border-radius: 20px;
    padding: 7px 14px; font-size: .875rem;
    background: var(--bg); color: var(--text); outline: none;
    transition: border-color .15s;
}
.ai-chat-input input:focus { border-color: #a78bfa; }
.ai-chat-input button {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    border: none; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s;
}
.ai-chat-input button:hover:not(:disabled) { opacity: .88; }
.ai-chat-input button:disabled { opacity: .5; cursor: not-allowed; }

[data-theme="dark"] .ai-bubble { background: #2e1065; color: var(--text); }
[data-theme="dark"] .ai-chat-typing { background: #2e1065; }
[data-theme="dark"] .ai-chat-input input { background: var(--bg); color: var(--text); }

@media (max-width: 400px) { .ai-chat-panel { width: calc(100vw - 32px); right: 0; } }
[data-noanim="on"] .ai-chat-panel { transition: none !important; }
