/* ============================================================================
   Physics Academy — Design System
   Primary #6C63FF · Secondary #FF6584 · BG #F8F9FA · Text #2D3436 · Inter
   ============================================================================ */

/* Inter is loaded non-render-blocking from the HTML <head> (see header.php).
   Never @import it here: a slow/unreachable fonts.googleapis.com blocks the
   whole page from rendering and can cause RESULT_CODE_HUNG in the browser.
   The system-font fallback in --font renders instantly if Inter is delayed. */

:root {
    /* Brand */
    --primary:       #6C63FF;
    --primary-600:   #5b52ec;
    --primary-700:   #4a42c4;
    --primary-50:    #EEEDFF;
    --secondary:     #FF6584;
    --secondary-600: #f5476b;

    /* Neutrals */
    --bg:            #F8F9FA;
    --surface:       #FFFFFF;
    --surface-2:     #F1F3F5;
    --text:          #2D3436;
    --muted:         #7A828A;
    --border:        #E7E9ED;

    /* Status */
    --success:    #2BB673;  --success-bg: #E6F7EF;
    --danger:     #FF4D4F;  --danger-bg:  #FFECEC;
    --info:       #3B82F6;  --info-bg:    #E8F1FE;
    --warning:    #F59E0B;

    /* Level badges */
    --beginner:     #2BB673;
    --intermediate: #F59E0B;
    --advanced:     #FF4D4F;

    /* Admin (dark) */
    --admin-bg:     #1E1B2E;
    --admin-bg-2:   #27233E;
    --admin-text:   #B9B6CC;
    --admin-hover:  #2F2A4A;

    /* Shape & depth */
    --radius:    14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow:    0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 6px 20px rgba(16,24,40,.08);
    --shadow-lg: 0 16px 40px rgba(108,99,255,.18);

    --maxw: 1180px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.page { padding: 32px 24px 64px; }
.section { margin: 48px 0; }
.section-title { font-size: 1.5rem; margin: 0 0 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head .section-title { margin: 0; }
.link-more { font-weight: 600; white-space: nowrap; }

/* ============================================================================
   1. Navigation bar
   ============================================================================ */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 70px; }
.brand {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 800; font-size: 1.2rem; color: var(--text); white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--primary); font-size: 1.3rem; }

/* Logo image (replaces the ⚛ brand-mark) */
.brand-logo { height: 54px; width: auto; display: block; }
.auth-brand .brand-logo { height: 68px; margin: 0 auto 4px; }
/* On dark surfaces the black wordmark needs a light chip to stay readable */
.admin-brand .brand-logo,
.footer-brand .brand-logo {
    height: 56px; background: #fff; padding: 6px 10px; border-radius: var(--radius-sm);
}
.footer-brand .brand-logo { height: 48px; }

.main-nav { flex: 1; display: flex; align-items: center; justify-content: space-between; }
.nav-center { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-center a, .nav-login {
    color: #4a5157; font-weight: 600; font-size: .95rem;
    padding: 8px 14px; border-radius: var(--radius-pill);
}
.nav-center a:hover, .nav-login:hover { background: var(--primary-50); color: var(--primary-700); text-decoration: none; }
.nav-center a.active { color: var(--primary-700); background: var(--primary-50); }
.nav-actions a.btn { padding: 9px 18px; }
.nav-user { color: var(--muted); font-size: .9rem; font-weight: 600; }

.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.6rem; cursor: pointer; line-height: 1; }

/* ============================================================================
   7. Buttons
   ============================================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; border: 1.5px solid transparent; border-radius: var(--radius-pill);
    background: var(--primary); color: #fff;
    padding: 11px 20px; font-weight: 600; font-size: .95rem; font-family: inherit;
    transition: transform .06s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { background: var(--primary-600); text-decoration: none; box-shadow: 0 6px 18px rgba(108,99,255,.28); }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary-700); box-shadow: none; }

.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-600); box-shadow: 0 6px 18px rgba(255,101,132,.3); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #e7383b; box-shadow: 0 6px 18px rgba(255,77,79,.3); }

.btn-done, .btn[disabled] { background: var(--success); cursor: default; opacity: .95; box-shadow: none; }
.btn[disabled] { pointer-events: none; }

/* ============================================================================
   Hero / homepage sections
   ============================================================================ */
.hero {
    background: linear-gradient(135deg, #efeefe 0%, #fdeef2 100%);
    border: 1px solid var(--border); border-radius: 24px;
    padding: 64px 48px; margin: 32px 0 48px; position: relative; overflow: hidden;
}
.hero::after {
    content: ''; position: absolute; right: -80px; top: -80px; width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(108,99,255,.18), transparent 70%); border-radius: 50%;
}
.hero h1 { font-size: 2.6rem; margin: 0 0 14px; font-weight: 800; letter-spacing: -.02em; }
.hero p { color: #555c63; font-size: 1.15rem; max-width: 560px; margin: 0 0 28px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* ============================================================================
   2. Course cards
   ============================================================================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 26px; }
.card-grid.grid-3 { grid-template-columns: repeat(3, 1fr); }

.course-card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
}
.course-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.course-card a { color: inherit; }
.course-card a:hover { text-decoration: none; }

.course-thumb {
    position: relative; aspect-ratio: 16 / 9; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.course-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 3rem; color: var(--primary); opacity: .55; }
.thumb-placeholder.large { font-size: 5rem; }
.thumb-badge { position: absolute; top: 12px; right: 12px; box-shadow: var(--shadow); }

.course-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }
.course-body h3 { margin: 6px 0 6px; font-size: 1.12rem; }
.instructor { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.course-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 12px; font-size: .9rem; }
.price { color: var(--primary-700); font-weight: 800; font-size: 1.05rem; }
.lessons { color: var(--muted); }
.course-card-foot { padding: 0 18px 18px; }
.course-rating { display: flex; align-items: center; gap: 8px; font-size: .85rem; margin-top: 10px; }

/* ============================================================================
   10. Badges  +  11. Star rating
   ============================================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: 4px 10px; border-radius: var(--radius-pill); background: var(--primary); color: #fff;
}
.badge-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.badge-success { background: var(--success); }
.badge-free { background: var(--success); }

/* Level badges: beginner=green, intermediate=orange, advanced=red */
.badge-beginner     { background: var(--beginner); }
.badge-intermediate { background: var(--intermediate); }
.badge-advanced     { background: var(--advanced); }

.stars { color: #FFB400; letter-spacing: 2px; line-height: 1; }
.course-rating .stars { font-size: 1rem; }

/* ============================================================================
   3. Progress bars
   ============================================================================ */
.progress { background: var(--surface-2); border-radius: var(--radius-pill); height: 9px; overflow: hidden; margin: 10px 0 6px; }
.progress-bar { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width .4s ease; }

/* ============================================================================
   8. Forms
   ============================================================================ */
label { display: block; margin-bottom: 16px; font-weight: 600; font-size: .92rem; color: #3a4046; }
label small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=tel], textarea, select {
    width: 100%; margin-top: 7px;
    background: var(--surface); color: var(--text);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 14px; font-size: .95rem; font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #aab0b6; }
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50);
}
/* Validation states */
input:not(:placeholder-shown):invalid, textarea:not(:placeholder-shown):invalid { border-color: var(--danger); }
input:not(:placeholder-shown):invalid:focus { box-shadow: 0 0 0 4px var(--danger-bg); }
.field-error { color: var(--danger); font-size: .82rem; margin-top: 4px; font-weight: 500; }
textarea { resize: vertical; min-height: 90px; }
label.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 500; }
label.checkbox input { width: auto; margin: 0; accent-color: var(--primary); }

.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; max-width: 960px; box-shadow: var(--shadow); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { display: flex; gap: 12px; margin-top: 10px; }
.hint { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; font-size: .82rem; }
.filter-bar { margin-bottom: 22px; max-width: 340px; }

/* Auth cards */
.auth-card {
    width: 100%; max-width: 440px; margin: 48px auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 0 0 22px; font-size: 1.5rem; text-align: center; }
.auth-alt { margin-top: 20px; text-align: center; color: var(--muted); }
.auth-brand { display: block; text-align: center; font-weight: 800; font-size: 1.25rem; color: var(--text); margin-bottom: 18px; }
.auth-brand:hover { text-decoration: none; color: var(--primary); }
.auth-page { display: flex; min-height: 100vh; }
.auth-page .container { display: flex; align-items: center; justify-content: center; }
.auth-card .checkbox { margin: 4px 0 18px; }
.admin-login-page { display: flex; align-items: center; min-height: 100vh; }

/* ============================================================================
   9. Flash messages
   ============================================================================ */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 16px;
    font-size: .92rem; font-weight: 500; border: 1px solid; border-left-width: 4px;
    animation: flash-in .25s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash::before { font-size: 1.05rem; }
.flash-success { background: var(--success-bg); border-color: var(--success); color: #1c7a4d; }
.flash-success::before { content: '✓'; }
.flash-error { background: var(--danger-bg); border-color: var(--danger); color: #c0363a; }
.flash-error::before { content: '⚠'; }
.flash-info { background: var(--info-bg); border-color: var(--info); color: #1f5fc0; }
.flash-info::before { content: 'ℹ'; }

/* ============================================================================
   Empty state / misc
   ============================================================================ */
.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state .btn { margin-top: 16px; }
.breadcrumb { margin-bottom: 16px; }
.breadcrumb a { font-weight: 600; }

/* ============================================================================
   Course detail page
   ============================================================================ */
.course-detail { padding-top: 12px; }

/* --- Course detail top: video + purchase card --- */
.course-top { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.course-video .video-wrap { margin: 0; }

.buy-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 24px; position: sticky; top: 24px; }
.buy-price { text-align: center; color: var(--text); line-height: 1; }
.buy-price .num { font-size: 2.6rem; font-weight: 800; }
.buy-price .cur { font-size: 1.15rem; font-weight: 700; color: var(--muted); }
.buy-sub { text-align: center; color: var(--muted); margin: 6px 0 20px; font-size: .95rem; }
.btn-buy { background: linear-gradient(180deg, #2f6fed, #1d5bd6); box-shadow: 0 6px 18px rgba(29,91,214,.28); font-size: 1.02rem; padding: 13px 20px; }
.btn-buy:hover { background: linear-gradient(180deg, #2a64d8, #1a52c2); box-shadow: 0 8px 22px rgba(29,91,214,.34); }
.buy-enrolled { text-align: center; margin: 12px 0 0; }
.buy-features { list-style: none; padding: 0; margin: 20px 0 0; border-top: 1px solid var(--border); }
.buy-features li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 2px; border-bottom: 1px solid var(--border); font-size: .92rem; color: #444b52; }
.buy-features .feat-chev { color: var(--muted); font-size: 1.1rem; }

/* --- Course lead: title + meta --- */
.course-lead { margin: 30px 0 6px; }
.course-lead h1 { margin: 8px 0 12px; font-size: 2rem; }
.course-lead-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .95rem; }
.meta-play { color: #1d5bd6; display: inline-flex; }
.course-lead .instructor { margin-top: 14px; }
.course-lead .course-desc { margin-top: 10px; }

/* --- Course program (lesson cards) --- */
.prog-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.prog-item { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); color: var(--text); transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
a.prog-item:hover { border-color: #1d5bd6; box-shadow: var(--shadow-md); text-decoration: none; }
.prog-item.is-locked { opacity: .75; }
.prog-num { width: 36px; height: 36px; flex: none; border-radius: 9px; background: #eef4ff; color: #1d5bd6; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.prog-title { flex: 1; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.prog-duration { color: var(--muted); font-size: .82rem; font-weight: 400; }
.prog-action { display: flex; align-items: center; gap: 10px; }
.prog-play { color: #1d5bd6; display: inline-flex; }
.prog-check { color: var(--success); font-weight: 800; }
.prog-item.is-active { border-color: #1d5bd6; box-shadow: 0 0 0 1px #1d5bd6 inset; }
.prog-item.is-active .prog-num { background: #1d5bd6; color: #fff; }

/* Lesson card variants (reuses .buy-card) */
.buy-card .lesson-dl { margin-top: 10px; }
.buy-features a { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; color: #444b52; }
.buy-features a:hover { color: #1d5bd6; text-decoration: none; }
.buy-features .feat-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.course-header { display: grid; grid-template-columns: 1fr 1.3fr; gap: 36px; align-items: center; margin-bottom: 8px; }
.course-header-media { aspect-ratio: 16/9; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); }
.course-header-media img { width: 100%; height: 100%; object-fit: cover; }
.course-header-info h1 { margin: 6px 0 10px; font-size: 2rem; }
.course-desc { color: #555c63; }
.enrolled-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Lesson list (course content) */
.lesson-list { list-style: none; padding: 0; margin: 0; }
.lesson-item { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 10px; transition: border-color .15s ease, box-shadow .15s ease; }
.lesson-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.lesson-index { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--primary-50); color: var(--primary-700); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.lesson-info { flex: 1; display: flex; flex-direction: column; }
.lesson-title { font-weight: 600; }
.lesson-duration { color: var(--muted); font-size: .82rem; }
.lesson-action { display: flex; align-items: center; gap: 10px; }
.check { color: var(--success); font-weight: 800; }
.lock { opacity: .45; }

/* Reviews */
.review-form { max-width: 660px; margin-bottom: 24px; }
.review-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.review-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow); }
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.review-item p { margin: 0; color: #555c63; }

/* ============================================================================
   4. Video player wrapper  +  lesson player layout  +  5. Lesson sidebar
   ============================================================================ */
.lesson-layout { display: grid; grid-template-columns: 1fr 320px; gap: 32px; align-items: start; padding-top: 8px; }
.lesson-main { min-width: 0; }
.video-wrap {
    position: relative; aspect-ratio: 16 / 9; width: 100%;
    background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.video-wrap iframe, .video-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #000; }
.video-missing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9aa0a6; }
.lesson-main h1 { font-size: 1.6rem; margin: 6px 0 10px; }
.lesson-desc { color: #555c63; }
.lesson-image { margin: 20px 0; }
.lesson-image img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.lesson-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

.lesson-nav { display: flex; justify-content: space-between; gap: 14px; margin-top: 28px; }
.lesson-nav-link { display: flex; flex-direction: column; gap: 3px; max-width: 48%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; color: var(--text); box-shadow: var(--shadow); }
.lesson-nav-link:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-2px); transition: transform .15s ease; }
.lesson-nav-link.next { text-align: right; margin-left: auto; align-items: flex-end; }
.lesson-nav-link .dir { font-size: .78rem; color: var(--primary); font-weight: 700; }
.lesson-nav-link .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Sidebar: fixed (sticky) right, scrollable lesson list */
.lesson-sidebar {
    position: sticky; top: 90px; align-self: start;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    max-height: calc(100vh - 110px); overflow-y: auto;
}
.lesson-sidebar h3 { margin: 0 0 4px; font-size: 1.05rem; }
.sidebar-progress { margin: 0 0 14px; font-size: .82rem; }
.sidebar-lessons { list-style: none; padding: 0; margin: 0; }
.sidebar-lessons li { margin-bottom: 4px; }
.sidebar-lessons li a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); transition: background .15s ease, padding-left .15s ease; }
.sidebar-lessons li a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar-lessons li.active a { background: var(--primary-50); padding-left: 16px; box-shadow: inset 3px 0 0 var(--primary); }
.sidebar-lessons li.active .title { color: var(--primary-700); font-weight: 700; }
.sidebar-lessons .num { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.sidebar-lessons .num-done { background: var(--success); color: #fff; }
.sidebar-lessons .title { flex: 1; font-size: .9rem; }
.sidebar-lessons .mini-free { margin-left: auto; font-size: .62rem; font-weight: 700; text-transform: uppercase; color: var(--success); border: 1px solid var(--success); border-radius: 5px; padding: 1px 5px; }
.mini-free { white-space: nowrap; }

/* ============================================================================
   Stats band / dashboard stats / testimonials / catalog
   ============================================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .9rem; }
.dash-stats { margin-top: 18px; }
.stat-revenue .stat-num { color: var(--success); }
.enrolled-courses { display: inline; }
.data-table td .enrolled-courses { color: var(--text); }

.activity-card { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.activity-icon { width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.activity-body { flex: 1; min-width: 0; }
.activity-line { margin: 0; }
.activity-time { font-size: .82rem; margin: 2px 0 0; }

.stats-band { background: linear-gradient(135deg, var(--primary), #8b7bff); border-radius: 20px; margin: 48px 0; padding: 40px 24px; box-shadow: var(--shadow-lg); }
.stats-inner { max-width: 820px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: center; }
.stats-band .stat-value { display: block; font-size: 2.4rem; font-weight: 800; color: #fff; }
.stats-band .stat-name { color: rgba(255,255,255,.88); font-size: .95rem; }

.testimonial { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin: 0; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.testimonial .stars { font-size: 1.1rem; }
.testimonial blockquote { margin: 0; font-style: italic; color: #41474d; }
.testimonial figcaption { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }

.catalog-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 22px 0 8px; }
.catalog-search { flex: 1 1 240px; margin: 0 !important; }
.level-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.level-tab { padding: 9px 16px; border-radius: var(--radius-pill); border: 1.5px solid var(--border); color: var(--muted); font-weight: 600; font-size: .85rem; }
.level-tab:hover { color: var(--primary-700); border-color: var(--primary); text-decoration: none; }
.level-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.result-count { color: var(--muted); margin: 8px 0 20px; }

/* ============================================================================
   Data tables (admin)
   ============================================================================ */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th, .data-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.data-table tr.row-unread { background: var(--info-bg); }
.data-table tr.row-unread:hover { background: #dbe8fd; }
.data-table td.msg-cell { max-width: 420px; white-space: normal; color: #555c63; }
.badge-info { background: var(--info); }
/* Admin message reply */
.msg-reply { margin-top: 10px; padding: 8px 12px; background: var(--info-bg); border-radius: var(--radius-sm); font-size: .9rem; }
.msg-reply-label { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--info); margin-bottom: 3px; }
.msg-reply-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.msg-reply-form textarea { flex: 1; min-height: 40px; margin-top: 0; }
/* Student message thread */
.msg-thread-list { display: grid; gap: 16px; }
.msg-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.msg-thread-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.msg-thread-body { margin: 0; color: #555c63; }
.msg-thread-reply { margin-top: 12px; padding: 10px 14px; background: var(--info-bg); border-radius: var(--radius-sm); }
.msg-thread-pending { margin: 10px 0 0; font-size: .88rem; }
/* Message attachment */
.msg-attach { display: inline-block; margin-top: 8px; font-size: .88rem; font-weight: 600; }
.msg-attach-img img { max-width: 200px; max-height: 160px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(16,24,40,.5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.15rem; }
.modal-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-body label { display: block; margin-bottom: 14px; font-weight: 600; }
.menu-badge { margin-inline-start: auto; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.data-table .truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table code { font-size: .78rem; color: var(--muted); background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.page-head-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.admin-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }

/* ============================================================================
   6. Admin layout — dark left sidebar
   ============================================================================ */
body.admin { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 248px; flex: none; background: var(--admin-bg); color: var(--admin-text);
    display: flex; flex-direction: column; padding: 22px 16px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.1rem; padding: 6px 10px 22px; }
.admin-brand:hover { text-decoration: none; color: #fff; }
.admin-brand .brand-mark { color: var(--primary); font-size: 1.3rem; }

.admin-menu { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.admin-menu .menu-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6f6a86; padding: 16px 12px 6px; }
.admin-menu a {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm);
    color: var(--admin-text); font-weight: 600; font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.admin-menu a:hover { background: var(--admin-hover); color: #fff; text-decoration: none; }
.admin-menu a.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(108,99,255,.35); }
.admin-menu .menu-icon { width: 20px; text-align: center; font-size: 1.05rem; flex: none; }
.admin-sidebar-foot { margin-top: auto; padding-top: 16px; }

.admin-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-main { flex: 1; padding: 32px 36px; max-width: 1100px; width: 100%; }
.admin-main h1 { font-size: 1.7rem; margin: 0 0 6px; }
.admin-footer { border-top: 1px solid var(--border); padding: 18px 36px; }
.admin-topbar { display: none; }

/* ============================================================================
   12. Footer (dark)
   ============================================================================ */
.site-footer { background: #1E1B2E; color: #B9B6CC; margin-top: 72px; padding: 48px 0 28px; }
.footer-inner { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 32px; }
.footer-brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; font-size: 1.15rem; margin-bottom: 10px; }
.footer-brand .brand-mark { color: var(--primary); }
.footer-col h4 { color: #fff; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 14px; }
.footer-col a { display: block; color: #B9B6CC; padding: 5px 0; font-size: .92rem; }
.footer-col a:hover { color: #fff; }
.footer-about { color: #908ca6; font-size: .9rem; max-width: 320px; }
.footer-bottom { max-width: var(--maxw); margin: 32px auto 0; padding: 22px 24px 0; border-top: 1px solid #322d47; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .85rem; color: #908ca6; }
.footer-bottom a { color: #B9B6CC; }

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 980px) {
    .card-grid.grid-3 { grid-template-columns: repeat(2, 1fr); }
    .admin-sidebar { width: 76px; padding: 18px 10px; }
    .admin-brand span:not(.brand-mark), .admin-menu .menu-text, .admin-menu .menu-label { display: none; }
    .admin-brand { padding: 6px 0 18px; justify-content: center; }
    .admin-brand .brand-logo { height: auto; max-width: 100%; padding: 4px; }
    .admin-menu a { justify-content: center; }
    .admin-main, .admin-footer { padding-left: 22px; padding-right: 22px; }
}
@media (max-width: 820px) {
    /* Compact header + smaller logo so it isn't cramped on phones */
    .header-inner { height: 60px; gap: 12px; }
    .brand-logo { height: 40px; }

    /* Hamburger as a proper 44px tap target, pushed to the end */
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        order: 3; margin-left: auto;
        width: 44px; height: 44px; margin-right: -8px;
        border-radius: var(--radius-sm); font-size: 1.7rem;
    }
    .nav-toggle:hover { background: var(--primary-50); color: var(--primary-700); }

    /* Slide-down menu panel anchored to the header's bottom edge */
    .main-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--surface); border-bottom: 1px solid var(--border);
        padding: 8px 16px 14px; box-shadow: var(--shadow-md);
        max-height: calc(100vh - 60px); overflow-y: auto;
    }
    .main-nav.open { display: flex; }
    .nav-center, .nav-actions { flex-direction: column; align-items: stretch; gap: 2px; margin: 0; }
    .main-nav a { width: 100%; }
    /* Full-width, comfortably tappable rows */
    .nav-center a, .nav-login {
        display: block; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 1rem;
    }
    /* Divider + full-width auth buttons below the links */
    .nav-actions { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
    .nav-actions .btn { width: 100%; padding: 12px 18px; }
    .nav-user { padding: 8px 14px; }
    /* Keep the header bar logo-left / hamburger-right on every page, even on
       RTL (Arabic) pages. The dropdown menu itself stays right-aligned below. */
    html[dir="rtl"] .header-inner { direction: ltr; }
    html[dir="rtl"] .main-nav { direction: rtl; text-align: right; }

    .course-header { grid-template-columns: 1fr; gap: 22px; }
    .course-top { grid-template-columns: 1fr; gap: 20px; }
    .buy-card { position: static; }
    .lesson-layout { grid-template-columns: 1fr; }
    .lesson-sidebar { position: static; max-height: none; order: -1; }
    .card-grid.grid-3, .card-grid { grid-template-columns: 1fr; }
    .stats-inner { grid-template-columns: 1fr; gap: 24px; }
    .catalog-filters { flex-direction: column; align-items: stretch; }
    .form-row { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .hero { padding: 44px 28px; }
    .hero h1 { font-size: 2rem; }

    /* Wide admin tables scroll horizontally instead of breaking the layout */
    .data-table {
        display: block; width: 100%;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .learner-stats { grid-template-columns: 1fr 1fr; }
    .learners-head { flex-direction: column; }
    .head-actions { width: 100%; }
    .head-actions .btn { flex: 1; }
}
@media (max-width: 560px) {
    /* Footer stacks into one centered column on phones */
    .footer-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .footer-col,
    html[dir="rtl"] .footer-col { text-align: center; }
    .footer-brand { justify-content: center; }
    .footer-about { max-width: none; }
    .footer-bottom { justify-content: center; text-align: center; }

    .page-head { flex-direction: column; align-items: flex-start; }
    .admin-main { padding: 22px 16px; }

    /* Tighter gutters so content isn't cramped against the screen edges */
    .container { padding: 0 16px; }
    .page { padding: 24px 16px 48px; }
    .section { margin: 32px 0; }

    /* Typography scales down for small screens */
    .hero { padding: 32px 20px; }
    .hero h1 { font-size: 1.6rem; }
    .section-title { font-size: 1.3rem; }

    /* Primary actions go full-width and are easy to tap */
    .hero-cta { flex-direction: column; align-items: stretch; }
    .hero-cta .btn { width: 100%; }
    .learner-stats { grid-template-columns: 1fr; }
    .admin-filters, .learner-filters, .catalog-filters { flex-direction: column; align-items: stretch; }
    .admin-filters .filter-reset { margin-left: 0; }
}

/* ---------- Admin upload fields ---------- */
.upload-field { display: block; margin-bottom: 18px; }
.upload-label { display: block; font-weight: 600; margin-bottom: 7px; }
.upload-label small { font-weight: 400; color: var(--muted); }
.upload-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-btn { cursor: pointer; margin: 0; }
.upload-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-clear {
    background: transparent; border: none; color: var(--danger);
    font-size: .85rem; cursor: pointer; padding: 4px 6px; text-decoration: underline;
}
.upload-clear:hover { opacity: .8; }
.upload-status { min-height: 1.2em; margin-top: 7px; font-size: .85rem; word-break: break-word; }
.upload-status.uploading { color: var(--primary-700); }
.upload-status .upload-ok, .upload-status.upload-ok { color: var(--success); font-weight: 600; }
.upload-status.upload-err { color: var(--danger); font-weight: 600; }

/* ============================================================
   Admin filter / search bar (Pages list, etc.)
   ============================================================ */
.admin-filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 18px;
}
.admin-filters .admin-search { flex: 1 1 240px; min-width: 200px; }
.admin-filters input[type="search"],
.admin-filters input[type="date"],
.admin-filters select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); font: inherit; color: var(--text);
}
.admin-filters label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.admin-filters .filter-reset { margin-left: auto; }

/* ============================================================
   Rich text editor
   ============================================================ */
.rte {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); overflow: hidden;
}
.rte-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding: 6px 8px; border-bottom: 1px solid var(--border);
    background: #FCFCFD;
}
.rte-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; }
.rte-group + .rte-group { border-left: 1px solid var(--border); }
.rte-group-end { margin-left: auto; border-left: none; }
.rte-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 7px;
    border: none; border-radius: 7px; background: transparent;
    color: var(--text); font-size: .9rem; cursor: pointer; line-height: 1;
}
.rte-btn:hover { background: var(--bg); }
.rte-btn:active { background: var(--border); }
.rte-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rte-btn svg text { stroke: none; fill: currentColor; }
.rte-btn[data-html] { font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--muted); }
.rte-tx { font-style: italic; }
.rte-select {
    height: 30px; padding: 0 26px 0 10px; border: 1px solid var(--border);
    border-radius: 7px; background: var(--surface); font: inherit; font-size: .85rem;
    color: var(--text); cursor: pointer;
}
.rte-body {
    min-height: 280px; max-height: 60vh; overflow-y: auto;
    padding: 16px 18px; outline: none; font-size: .98rem; line-height: 1.6;
}
.rte-body:focus { box-shadow: inset 0 0 0 2px rgba(108,99,255,.12); }
.rte-body h1 { font-size: 1.7rem; margin: .6em 0 .3em; }
.rte-body h2 { font-size: 1.4rem; margin: .6em 0 .3em; }
.rte-body h3 { font-size: 1.15rem; margin: .6em 0 .3em; }
.rte-body p { margin: 0 0 .8em; }
.rte-body ul, .rte-body ol { margin: 0 0 .8em 1.4em; }
.rte-body blockquote {
    margin: 0 0 .8em; padding: 6px 14px; border-left: 3px solid var(--primary);
    color: var(--muted); background: var(--bg); border-radius: 4px;
}
.rte-body code {
    background: var(--bg); padding: 1px 5px; border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
}
.rte-body img { max-width: 100%; height: auto; border-radius: 6px; }
.rte-source {
    width: 100%; min-height: 280px; max-height: 60vh; padding: 16px 18px;
    border: none; outline: none; resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; line-height: 1.5;
}
.rte-fullscreen {
    position: fixed; inset: 0; z-index: 1000; border-radius: 0;
    display: flex; flex-direction: column;
}
.rte-fullscreen .rte-body,
.rte-fullscreen .rte-source { flex: 1; max-height: none; }

/* Public CMS page render */
.page-content { font-size: 1.02rem; line-height: 1.7; }
.page-content h2 { margin-top: 1.4em; }
.page-content img { max-width: 100%; height: auto; border-radius: 8px; }
.page-content blockquote {
    margin: 1em 0; padding: 8px 16px; border-left: 3px solid var(--primary);
    color: var(--muted); background: var(--bg); border-radius: 4px;
}

/* ============================================================
   RTL / Arabic landing page (applied via <html dir="rtl"> + body.rtl)
   ============================================================ */
html[dir="rtl"] body,
body.rtl {
    font-family: 'Segoe UI', Tahoma, 'Geeza Pro', 'Noto Naskh Arabic', 'Arabic Typesetting', sans-serif;
}
html[dir="rtl"] .hero-text,
html[dir="rtl"] .section,
html[dir="rtl"] .section-title,
html[dir="rtl"] .testimonial,
html[dir="rtl"] .footer-col { text-align: right; }
html[dir="rtl"] .hero-cta,
html[dir="rtl"] .section-head { flex-direction: row-reverse; }
html[dir="rtl"] blockquote { border-left: none; border-right: 3px solid var(--primary); }

/* ============================================================
   Admin: Learner management (students.php)
   ============================================================ */
.learners-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.learners-head h1 { margin-bottom: 2px; }
.head-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* Stat cards with leading icon */
.learner-stats { grid-template-columns: repeat(4, 1fr); margin: 18px 0 6px; }
.learner-stats .stat-card { flex-direction: row; align-items: center; gap: 14px; }
.learner-stats .stat-card > div { display: flex; flex-direction: column; }
.learner-stats .stat-label { order: 0; font-size: .82rem; color: var(--muted); }
.learner-stats .stat-num { order: 1; font-size: 1.6rem; font-weight: 700; }
.stat-ic {
    width: 44px; height: 44px; border-radius: 12px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.ic-blue   { background: #EAF0FF; }
.ic-green  { background: #E6F7EF; }
.ic-purple { background: #F0EAFF; }
.ic-red    { background: #FFECEC; }

/* Filter bar */
.learner-filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; margin: 14px 0 18px;
}
.learner-filters input[type="search"],
.learner-filters input[type="date"],
.learner-filters select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); font: inherit; color: var(--text);
}
.learner-filters .lf-search { flex: 1 1 200px; min-width: 160px; }
.learner-filters .lf-search input { width: 100%; }

/* Table specifics */
.learner-table th, .learner-table td { vertical-align: middle; }
.col-check { width: 38px; text-align: center; }
.learner-cell { display: flex; align-items: center; gap: 12px; }
.learner-id { display: flex; flex-direction: column; line-height: 1.3; }
.learner-id .muted { font-size: .82rem; }
.student-avatar {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: #E6ECFF; color: var(--primary-700, #4b45c6);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}
.progress-inline { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.progress-inline .progress { flex: 1; margin: 0; }
.progress-pct { font-size: .8rem; color: var(--muted); min-width: 32px; }

/* Status badges with a leading dot */
.badge-status { display: inline-flex; align-items: center; gap: 6px; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active    { background: var(--success-bg); color: var(--success); }
.badge-suspended { background: #FFF4E5; color: var(--warning); }
.badge-banned    { background: var(--danger-bg); color: var(--danger); }
