/* ── Design tokens ── */
:root {
  --primary:        #2B6CB0;
  --primary-light:  #63B3ED;
  --primary-dark:   #1A365D;
  --secondary:      #38A169;
  --bg:             #F7FAFC;
  --bg-card:        #FFFFFF;
  --bg-hover:       #EDF2F7;
  --bg-alt:         #EBF8FF;
  --border:         #E2E8F0;
  --text:           #2D3748;
  --text-muted:     #718096;
  --text-light:     #A0AEC0;
  --accent:         #3182CE;
  --accent-light:   #BEE3F8;
  --success:        #38A169;
  --warning:        #D69E2E;
  --danger:         #E53E3E;
  --radius-sm:      6px;
  --radius:         12px;
  --radius-lg:      18px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  font-family: 'Tajawal', sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }

/* ── Container ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
@media (max-width: 640px) { .container { padding: 0 1rem; } }

/* ── Card ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-flat { box-shadow: var(--shadow); border: none; }
.card-clickable { cursor: pointer; text-decoration: none; color: inherit; display: block; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.3rem; border-radius: var(--radius-sm); font-size: .9rem;
  font-weight: 600; cursor: pointer; border: none; text-decoration: none;
  font-family: inherit; transition: all .15s ease;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #2F855A; }
.btn-ghost { border: 1.5px solid var(--border); color: var(--text); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4rem .9rem; font-size: .82rem; }
.btn-lg { padding: .8rem 2rem; font-size: 1rem; }

/* ── Inputs ── */
input, select, textarea {
  width: 100%; padding: .6rem .9rem; background: var(--bg-card);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: .95rem; font-family: inherit;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(99,179,237,.2);
}
label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--text-muted); text-align: right; }
.field-error { color: var(--danger); font-size: .8rem; margin-top: .2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 60px;
  background: rgba(255,255,255,.95); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.nav-logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; color: var(--primary); }
.nav-logo small { font-weight: 300; font-size: .75rem; color: var(--text-muted); }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--text-muted); font-size: .9rem; cursor: pointer; padding: .3rem .6rem; border-radius: var(--radius-sm); transition: all .2s; }
.nav-link:hover,.nav-link.active { color: var(--primary); background: var(--bg-alt); }
.nav-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: .4rem; }
@media (max-width: 768px) {
  .nav-links { display: none; position: absolute; top: 60px; right: 0; left: 0; background: var(--bg-card); flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md); }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
}

/* ── Hero ── */
.hero {
  text-align: center; padding: 4rem 1rem 3rem;
  background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; color: var(--primary-dark); margin-bottom: .75rem; line-height: 1.2; }
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 600px; margin: 0 auto 1.5rem; }
.hero-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; color: var(--primary); background: var(--accent-light); padding: .25rem .8rem; border-radius: 999px; margin-bottom: 1rem; }

/* ── Section ── */
.section { padding: 3rem 0; }
.section-title { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); margin-bottom: .25rem; }
.section-sub { color: var(--text-muted); font-size: .95rem; margin-bottom: 1.5rem; }

/* ── Grids ── */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 640px) { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; }
.badge.blue { background: var(--accent-light); color: var(--primary); }
.badge.green { background: #C6F6D5; color: #276749; }
.badge.amber { background: #FEFCBF; color: #975A16; }
.badge.red { background: #FED7D7; color: #9B2C2C; }

/* ── Course header ── */
.course-header { padding: 2rem 0 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.course-header h1 { font-size: 1.6rem; font-weight: 800; color: var(--primary-dark); }
.course-info { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin-top: .75rem; color: var(--text-muted); font-size: .88rem; }
.course-info span { display: flex; align-items: center; gap: .3rem; }

/* ── Video player ── */
.video-player-wrap { background: #0a1628; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; position: relative; }
.video-placeholder { color: rgba(255,255,255,.5); text-align: center; padding: 2rem; }
.video-placeholder h3 { color: #fff; font-size: 1.15rem; font-weight: 700; margin-bottom: .3rem; }
.video-placeholder p { font-size: .85rem; }
.video-player-wrap video { width: 100%; height: 100%; }

/* ── Playlist ── */
.playlist { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.playlist-item { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .15s; }
.playlist-item:last-child { border-bottom: none; }
.playlist-item:hover { background: var(--bg-hover); }
.playlist-item.active { background: var(--bg-alt); border-right: 3px solid var(--primary); }
.playlist-item .num { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-hover); display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 600; flex-shrink: 0; }
.playlist-item.active .num { background: var(--primary); color: #fff; }
.playlist-item .info { flex: 1; min-width: 0; }
.playlist-item .info .name { font-size: .88rem; font-weight: 500; }
.playlist-item .info .meta { font-size: .75rem; color: var(--text-muted); }
.playlist-item .check { color: var(--success); flex-shrink: 0; }

/* ── Lesson layout ── */
.lesson-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 860px) { .lesson-layout { grid-template-columns: 1fr; } }

/* ── Admin ── */
.admin-layout { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 60px); }
.admin-sidebar { background: var(--bg-card); border-left: 1px solid var(--border); padding: 1.25rem; }
.admin-sidebar .menu-item { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .88rem; color: var(--text-muted); transition: all .15s; margin-bottom: .25rem; }
.admin-sidebar .menu-item:hover { background: var(--bg-hover); color: var(--text); }
.admin-sidebar .menu-item.active { background: var(--bg-alt); color: var(--primary); font-weight: 600; }
.admin-content { padding: 1.5rem; }
@media (max-width: 768px) { .admin-layout { grid-template-columns: 1fr; } }

/* ── Stat card ── */
.stat-card { text-align: center; padding: 1.25rem; }
.stat-card .num { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: .75rem 1rem; border-bottom: 2px solid var(--border); }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
tr:hover td { background: var(--bg-hover); }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 1.5rem; left: 1.5rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .75rem 1.25rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: fadeUp .3s ease; }
.toast.success { background: #C6F6D5; border: 1px solid #9AE6B4; color: #276749; }
.toast.error { background: #FED7D7; border: 1px solid #FEB2B2; color: #9B2C2C; }
.toast.info { background: #BEE3F8; border: 1px solid #90CDF4; color: #2C5282; }

/* ── Modal ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); padding: 2rem; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; }

/* ── Auth ── */
.auth-wrap { max-width: 420px; margin: 3rem auto; padding: 2rem; text-align: center; }
.auth-wrap h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.auth-wrap p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-wrap form { display: flex; flex-direction: column; gap: 1rem; text-align: right; }
.auth-switch { margin-top: 1rem; font-size: .88rem; color: var(--text-muted); }
.auth-switch a { color: var(--primary); cursor: pointer; font-weight: 600; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:none } }
.fade-up { animation: fadeUp .4s ease forwards; }
.delay-1 { animation-delay: .1s; opacity: 0; }
.delay-2 { animation-delay: .2s; opacity: 0; }
.delay-3 { animation-delay: .3s; opacity: 0; }

/* ── Progress ── */
.progress-bar-wrap { height: 6px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 999px; transition: width .3s; }

/* ── Footer ── */
.footer { border-top: 1px solid var(--border); padding: 2rem 0; text-align: center; color: var(--text-muted); font-size: .85rem; }
.footer .logo { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-bottom: .5rem; color: var(--primary); font-weight: 700; }

/* ── Empty / loading ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { margin-bottom: .75rem; opacity: .35; }
.empty-state p { font-size: .95rem; }
.skeleton { background: linear-gradient(90deg,#edf2f7 25%,#e2e8f0 50%,#edf2f7 75%); background-size: 200%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); height: 1rem; margin-bottom: .5rem; }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* ── File upload area ── */
.file-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; cursor: pointer; transition: all .2s; }
.file-zone:hover { border-color: var(--primary-light); background: var(--bg-alt); }

/* ── Icon helper ── */
.icon-24 { width: 24px; height: 24px; }
.icon-20 { width: 20px; height: 20px; }
.icon-16 { width: 16px; height: 16px; }
