/* =====================================================
   ONLINE LEARNING PLATFORM - MAIN STYLESHEET
   Design: "Notebook & Signal" — a study-app palette built
   around an indigo focus color and a warm amber progress
   accent (the color of a highlighter on a notebook page).
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* ---- Color tokens ---- */
    --ink: #1A1B2E;            /* near-black with a violet undertone, for text */
    --paper: #FBFAF8;          /* warm off-white background, like notebook paper */
    --surface: #FFFFFF;
    --surface-2: #F4F2FB;      /* faint violet-tinted panel */
    --primary: #4B3CFA;        /* focus indigo - main brand color */
    --primary-dark: #3A2DD0;
    --primary-light: #EDEAFF;
    --accent: #FFB347;         /* highlighter amber - progress / CTA accent */
    --accent-dark: #F08C1C;
    --success: #1FA77A;
    --danger: #E5484D;
    --warning: #F0A500;
    --border: #E8E6F0;
    --text-muted: #6E6B85;
    --text-faint: #9C99B0;

    /* ---- Layout tokens ---- */
    --sidebar-w: 268px;
    --topbar-h: 68px;
    --bottomnav-h: 64px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 2px 8px rgba(26, 27, 46, 0.06);
    --shadow-md: 0 8px 24px rgba(26, 27, 46, 0.10);
    --shadow-lg: 0 16px 40px rgba(26, 27, 46, 0.14);

    /* ---- Type ---- */
    --font-display: 'Manrope', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .display {
    font-family: var(--font-display);
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.01em;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* =====================================================
   APP SHELL LAYOUT
   ===================================================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- SIDEBAR (desktop) ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo-mark {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), #7B6CFF);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--font-display); font-weight: 800;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 17px;
    line-height: 1.1;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
}

.sidebar-nav .nav-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    padding: 16px 12px 8px;
}

.sidebar-nav a.nav-item, .sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14.5px;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.sidebar-nav a.nav-item svg, .sidebar-nav .nav-item svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
}

.sidebar-nav a.nav-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.sidebar-nav a.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav a.nav-item.active::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%; transform: translateY(-50%);
    width: 4px; height: 22px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.sidebar-user img {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-light);
}

.sidebar-user .u-name { font-weight: 700; font-size: 13.5px; }
.sidebar-user .u-role { font-size: 11.5px; color: var(--text-faint); }

/* ---------- MAIN CONTENT AREA ---------- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- TOP BAR ---------- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar .page-title {
    font-size: 19px;
    font-weight: 800;
    font-family: var(--font-display);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    position: relative;
    transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

.notif-dot {
    position: absolute;
    top: 7px; right: 8px;
    width: 8px; height: 8px;
    background: var(--accent-dark);
    border: 2px solid var(--surface);
    border-radius: 50%;
}

.hamburger-btn {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: transparent; border: none;
    color: var(--ink);
}
.hamburger-btn svg { width: 24px; height: 24px; }

/* ---------- PAGE CONTENT ---------- */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ---------- BOTTOM NAV (mobile) ---------- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 -4px 16px rgba(26,27,46,0.06);
}

.bottom-nav ul {
    display: flex;
    height: 100%;
}

.bottom-nav li { flex: 1; }

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
}

.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--primary); }

.bottom-nav .fab-slot {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-top: -26px;
}

.bottom-nav .fab {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7B6CFF);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 8px 20px rgba(75,60,250,0.4);
}
.bottom-nav .fab svg { width: 24px; height: 24px; }

/* =====================================================
   COMPONENTS
   ===================================================== */

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 14px;
    border: none;
    transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(75,60,250,0.28); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent { background: var(--accent); color: #1A1B2E; box-shadow: 0 4px 14px rgba(255,179,71,0.35); }
.btn-accent:hover { background: var(--accent-dark); }

.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--ink); }
.btn-outline:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--ink); }

.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-block { width: 100%; }

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

.card-pad { padding: 22px; }

/* ---- Course Card ---- */
.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.18s, box-shadow 0.18s;
    display: flex;
    flex-direction: column;
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.course-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--surface-2);
}

.course-card-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }

.course-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
    width: fit-content;
}

.course-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.35;
}

.course-meta {
    font-size: 12.5px;
    color: var(--text-faint);
    margin-bottom: 14px;
}

.course-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.price-tag { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--ink); }
.price-strike { text-decoration: line-through; color: var(--text-faint); font-size: 13px; font-weight: 500; margin-right: 6px; }
.price-free { color: var(--success); font-weight: 800; }

.progress-track {
    width: 100%;
    height: 7px;
    background: var(--surface-2);
    border-radius: 10px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 10px; }

/* ---- Grid layouts ---- */
.grid {
    display: grid;
    gap: 20px;
}
.grid-courses { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Stat cards (admin dashboard) ---- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.violet { background: var(--primary-light); color: var(--primary); }
.stat-icon.amber { background: #FFF3E0; color: var(--accent-dark); }
.stat-icon.green { background: #E3F7EF; color: var(--success); }
.stat-icon.red { background: #FDEBEC; color: var(--danger); }

.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--text-faint); font-weight: 600; margin-top: 2px; }

/* ---- Accordion (subjects -> chapters) ---- */
.accordion-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}
.accordion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
}
.accordion-head .count-badge {
    font-size: 11.5px;
    color: var(--text-faint);
    font-weight: 600;
    background: var(--surface-2);
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 10px;
}
.accordion-head svg.chevron { width: 18px; height: 18px; transition: transform 0.2s; color: var(--text-faint); }
.accordion-item.open .chevron { transform: rotate(180deg); }

.accordion-body { display: none; border-top: 1px solid var(--border); }
.accordion-item.open .accordion-body { display: block; }

.chapter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.chapter-row:last-child { border-bottom: none; }
.chapter-row-title { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 14px; }
.chapter-row-title .ch-num {
    width: 26px; height: 26px;
    border-radius: 8px;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    flex-shrink: 0;
}
.chapter-actions { display: flex; gap: 8px; }
.chapter-pill {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 700;
    padding: 7px 13px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
}
.chapter-pill:hover { background: var(--surface-2); color: var(--primary); border-color: var(--primary-light); }
.chapter-pill svg { width: 15px; height: 15px; }

/* ---- List rows (video list / notes list) ---- */
.list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 10px;
    transition: background 0.15s;
}
.list-row:hover { background: var(--surface-2); }
.list-row-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.list-row-icon svg { width: 20px; height: 20px; }
.list-row-icon.pdf-icon { background: #FDEBEC; color: var(--danger); }
.list-row-title { font-weight: 700; font-size: 14.5px; }
.list-row-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.list-row-action { margin-left: auto; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--ink); }
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.radio-group { display: flex; gap: 10px; }
.radio-option {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
}
.radio-option.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.radio-option input { display: none; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    font-weight: 700;
    padding: 14px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge-success { background: #E3F7EF; color: var(--success); }
.badge-warning { background: #FFF3E0; color: var(--warning); }
.badge-danger { background: #FDEBEC; color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

/* ---- Auth pages ---- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    padding: 20px;
}
.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    border: 1px solid var(--border);
}
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth-title { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-faint); font-size: 13.5px; margin-bottom: 26px; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-muted); }
.auth-footer a { color: var(--primary); font-weight: 700; }

/* ---- Notification page ---- */
.notif-card {
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 10px;
    position: relative;
}
.notif-card.unread { background: var(--primary-light); border-color: var(--primary-light); }
.notif-card.unread::before {
    content: '';
    position: absolute;
    left: 0; top: 16px; bottom: 16px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}
.notif-icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}
.notif-icon svg { width: 19px; height: 19px; }
.notif-title { font-weight: 700; font-size: 14px; }
.notif-msg { font-size: 13px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.notif-time { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; }

/* ---- Video Player Page ---- */
.player-wrap {
    background: #0E0E16;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16/9;
    position: relative;
}
.player-wrap video, .player-wrap iframe { width: 100%; height: 100%; border: none; }

.video-playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
}
.video-playlist-item:hover { background: var(--surface-2); }
.video-playlist-item.active { background: var(--primary-light); }
.video-playlist-item .play-num {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    flex-shrink: 0;
}
.video-playlist-item.active .play-num { background: var(--primary); color: #fff; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(26,27,46,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--text-faint); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.modal-close:hover { background: var(--surface-2); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Flash alerts ---- */
.alert { padding: 13px 18px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #E3F7EF; color: #157A56; }
.alert-error { background: #FDEBEC; color: #C53034; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Section heading ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-head h2 { font-size: 18px; font-weight: 800; }
.section-head a, .section-head .link-btn { font-size: 13px; font-weight: 700; color: var(--primary); }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    .grid-courses { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 880px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .hamburger-btn { display: flex; }
    .bottom-nav { display: block; }
    body { padding-bottom: var(--bottomnav-h); }
    .page-content { padding: 18px; padding-bottom: 90px; }
    .topbar { padding: 0 16px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(26,27,46,0.4);
        z-index: 99;
    }
    .sidebar-overlay.open { display: block; }
}

@media (max-width: 560px) {
    .grid-courses { grid-template-columns: 1fr 1fr; gap: 12px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .auth-box { padding: 28px 22px; }
    .course-title { font-size: 14px; }
    .topbar .page-title { font-size: 16px; }
}
