/* ==============================================================
   OKEDO PLATFORM — DESIGN SYSTEM (LIGHT, PROFESSIONAL, FRIENDLY)
   Brand: Deep Blue #1A3A8F · Amber #F5A623 · Sky Blue #3EADF0
   ============================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Nunito:wght@400;500;600;700&display=swap');

/* -------------------------------------------------------------- */
/* CSS CUSTOM PROPERTIES                                           */
/* -------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --blue:        #1A3A8F;
  --blue-mid:    #2552C5;
  --blue-light:  #3EADF0;
  --blue-pale:   #EBF3FF;
  --amber:       #F5A623;
  --amber-light: #FFF3D6;
  --amber-dark:  #D4881A;
  --sky:         #3EADF0;
  --sky-light:   #E0F4FF;

  /* Neutrals */
  --white:       #FFFFFF;
  --bg:          #F4F6FB;
  --bg-card:     #FFFFFF;
  --bg-hover:    #F8F9FD;
  --border:      #E2E8F0;
  --border-mid:  #CBD5E1;

  /* Text */
  --text-dark:   #0F172A;
  --text-body:   #334155;
  --text-muted:  #64748B;
  --text-subtle: #94A3B8;

  /* Status */
  --green:  #16A34A;
  --red:    #DC2626;
  --purple: #7C3AED;
  --teal:   #0D9488;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl:  0 20px 50px rgba(0,0,0,0.12);
  --shadow-blue:   0 4px 20px rgba(26,58,143,0.18);
  --shadow-amber:  0 4px 20px rgba(245,166,35,0.25);

  /* Spacing */
  --s-xs:  4px;
  --s-sm:  8px;
  --s-md:  16px;
  --s-lg:  24px;
  --s-xl:  32px;
  --s-2xl: 48px;

  /* Border Radius */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-2xl:  32px;
  --r-full: 9999px;

  /* Fonts */
  --font-heading: 'Poppins', sans-serif;
  --font-body:    'Nunito', sans-serif;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h:  64px;
  --mobile-nav-h: 60px;

  /* Transitions */
  --t-fast:   all 0.15s ease;
  --t-normal: all 0.25s ease;
  --t-slow:   all 0.4s cubic-bezier(0.16,1,0.3,1);
}

/* -------------------------------------------------------------- */
/* RESET                                                           */
/* -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-body);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: var(--font-body); }
input, textarea, select { font-family: var(--font-body); }

/* -------------------------------------------------------------- */
/* TYPOGRAPHY                                                      */
/* -------------------------------------------------------------- */
h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.25;
}
h1 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); }
h3 { font-size: clamp(1.05rem, 2vw, 1.35rem); }
h4 { font-size: 1.1rem; }
p  { color: var(--text-body); }

/* -------------------------------------------------------------- */
/* LAYOUT                                                          */
/* -------------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.sidebar-logo {
  padding: 20px var(--s-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: var(--r-sm);
}

.sidebar-logo .brand-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--blue);
  line-height: 1.1;
}

.sidebar-logo .brand-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.sidebar-user {
  padding: var(--s-md) var(--s-lg);
  background: var(--blue-pale);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

.user-avatar {
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  background: var(--blue);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-avatar.admin-av { background: linear-gradient(135deg, var(--amber-dark), var(--amber)); }

.user-info-name { font-weight: 700; font-size: 0.875rem; color: var(--text-dark); line-height: 1.2; }
.user-info-role { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }

.sidebar-nav { flex: 1; padding: var(--s-md) var(--s-sm); }

.nav-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  padding: var(--s-md) var(--s-md) var(--s-xs);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 10px var(--s-md);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--t-fast);
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-dark);
}

.nav-link.active {
  background: var(--blue-pale);
  color: var(--blue);
}

.nav-link.active .nav-link-icon { color: var(--blue); }

.nav-link-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--text-dark);
  transition: var(--t-fast);
}

.nav-link:hover .nav-link-icon { color: var(--text-dark); }

.sidebar-footer {
  padding: var(--s-md) var(--s-sm);
  border-top: 1px solid var(--border);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  width: 100%;
  padding: 10px var(--s-md);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--t-fast);
}
.btn-logout:hover { background: #FEF2F2; color: var(--red); }

/* ─── MAIN CONTENT ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: var(--s-md); }
.topbar-right { display: flex; align-items: center; gap: var(--s-sm); }
.topbar-title { font-family: var(--font-heading); font-size: 1rem; font-weight: 700; color: var(--text-dark); }
.topbar-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }

/* Mobile Hamburger */
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 150;
}

.page-wrapper { flex: 1; padding: var(--s-xl); }

/* -------------------------------------------------------------- */
/* BUTTONS                                                         */
/* -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font-body);
  transition: var(--t-normal);
  cursor: pointer;
  white-space: nowrap;
  border: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover { background: var(--blue-mid); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(26,58,143,0.25); }
.btn-primary:active { transform: translateY(0); }

.btn-amber {
  background: var(--amber);
  color: white;
  box-shadow: var(--shadow-amber);
}
.btn-amber:hover { background: var(--amber-dark); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-body);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-pale); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-dark); border-color: var(--border); }

.btn-danger {
  background: #FEF2F2;
  color: var(--red);
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--r-lg); }
.btn-icon { padding: 8px; border-radius: var(--r-md); }
.btn-icon-sm { padding: 6px; border-radius: var(--r-sm); }

/* -------------------------------------------------------------- */
/* CARDS                                                           */
/* -------------------------------------------------------------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
  box-shadow: var(--shadow-sm);
}

/* Subject Card */
.subject-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-lg);
  cursor: pointer;
  transition: var(--t-normal);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-md);
  position: relative;
  overflow: hidden;
}

.subject-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.subject-card-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}

.subject-icon-wrap {
  width: 52px; height: 52px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
}

.subject-name { font-family: var(--font-heading); font-weight: 700; font-size: 1rem; color: var(--text-dark); }
.subject-meta { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* Stat Card */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
  display: flex;
  align-items: center;
  gap: var(--s-md);
  box-shadow: var(--shadow-sm);
  transition: var(--t-fast);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon-wrap {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value { font-family: var(--font-heading); font-size: 1.75rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.stat-label { font-size: 0.775rem; color: var(--text-muted); font-weight: 600; margin-top: 3px; }

/* -------------------------------------------------------------- */
/* BADGES                                                          */
/* -------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-pale); color: var(--blue); }
.badge-amber  { background: var(--amber-light); color: var(--amber-dark); }
.badge-sky    { background: var(--sky-light); color: #0369A1; }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEF2F2; color: var(--red); }
.badge-purple { background: #F5F3FF; color: var(--purple); }
.badge-gray   { background: #F1F5F9; color: var(--text-muted); }

/* -------------------------------------------------------------- */
/* FORMS                                                           */
/* -------------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: var(--s-xs); margin-bottom: var(--s-md); }
.form-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-body);
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  color: var(--text-dark);
  font-size: 0.9rem;
  font-family: var(--font-body);
  font-weight: 500;
  transition: var(--t-fast);
  outline: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,58,143,0.08);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-subtle); font-weight: 400; }
.form-textarea { resize: vertical; min-height: 130px; line-height: 1.7; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
.form-select option { background: white; color: var(--text-dark); }
.form-hint  { font-size: 0.78rem; color: var(--text-muted); }
.form-error { font-size: 0.78rem; color: var(--red); font-weight: 600; }

.input-wrap { position: relative; }
.input-wrap .input-ico {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}
.input-wrap .form-input { padding-left: 42px; }

/* -------------------------------------------------------------- */
/* ACCORDION                                                       */
/* -------------------------------------------------------------- */
.accordion { display: flex; flex-direction: column; gap: var(--s-sm); }

.accordion-item {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: var(--t-fast);
}
.accordion-item:hover { border-color: var(--blue); }
.accordion-item.open  { border-color: var(--blue); }

.accordion-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  padding: var(--s-md) var(--s-lg);
  cursor: pointer;
  transition: var(--t-fast);
  user-select: none;
}
.accordion-trigger:hover { background: var(--bg-hover); }

.acc-num {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--blue-pale);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 800;
  flex-shrink: 0;
  font-family: var(--font-heading);
}
.accordion-item.open .acc-num { background: var(--blue); color: white; }

.acc-title { flex: 1; font-weight: 700; font-size: 0.93rem; color: var(--text-dark); }
.acc-count { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.acc-chevron {
  width: 18px; height: 18px;
  color: var(--text-subtle);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
.accordion-item.open .acc-chevron { transform: rotate(180deg); color: var(--blue); }

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
}
.accordion-item.open .accordion-body { max-height: 2000px; }

.subbab-list { padding: var(--s-xs) var(--s-md) var(--s-md); }

.subbab-row {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 10px var(--s-sm);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--t-fast);
  text-decoration: none;
  color: var(--text-body);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.subbab-row:hover {
  background: var(--blue-pale);
  border-color: rgba(26,58,143,0.12);
  color: var(--blue);
}

.subbab-lbl {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-heading);
}
.subbab-row:hover .subbab-lbl { background: var(--blue); border-color: var(--blue); color: white; }

/* -------------------------------------------------------------- */
/* BREADCRUMB                                                      */
/* -------------------------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  margin-bottom: var(--s-lg);
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 4px;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb a { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; transition: var(--t-fast); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb-sep { font-size: 0.7rem; color: var(--text-subtle); }
.breadcrumb-cur { font-size: 0.8rem; color: var(--text-dark); font-weight: 700; }

/* -------------------------------------------------------------- */
/* EMBED PLAYER                                                    */
/* -------------------------------------------------------------- */
.embed-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-md);
}
.embed-container iframe {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: none;
}
.embed-empty {
  width: 100%;
  padding-top: 56.25%;
  position: relative;
  background: var(--bg);
  border: 2px dashed var(--border-mid);
  border-radius: var(--r-lg);
}
.embed-empty-inner {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s-sm);
  color: var(--text-subtle);
}

/* -------------------------------------------------------------- */
/* TABLES                                                          */
/* -------------------------------------------------------------- */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
th {
  padding: 11px 16px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  font-size: 0.875rem;
  color: var(--text-body);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* -------------------------------------------------------------- */
/* MODAL                                                           */
/* -------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-lg);
  opacity: 0; visibility: hidden;
  transition: all 0.2s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-xl);
  max-width: 480px; width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.97);
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-lg);
  padding-bottom: var(--s-md);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-heading); font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; font-size: 1rem;
  transition: var(--t-fast);
}
.modal-close:hover { background: #FEF2F2; color: var(--red); border-color: #FECACA; }
.modal-footer {
  display: flex; gap: var(--s-sm); justify-content: flex-end;
  margin-top: var(--s-lg); padding-top: var(--s-lg);
  border-top: 1px solid var(--border);
}

/* -------------------------------------------------------------- */
/* TOAST                                                           */
/* -------------------------------------------------------------- */
.toast-container {
  position: fixed; top: var(--s-lg); right: var(--s-lg);
  z-index: 9999;
  display: flex; flex-direction: column; gap: var(--s-sm);
}
.toast {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 13px 16px;
  display: flex; align-items: center; gap: var(--s-sm);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  animation: toastIn 0.4s cubic-bezier(0.16,1,0.3,1) forwards;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-dark);
}
.toast.hide { animation: toastOut 0.3s ease forwards; }
.toast-ok  { border-left: 3px solid var(--green); }
.toast-err { border-left: 3px solid var(--red); }
@keyframes toastIn  { from { opacity:0; transform:translateX(60px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(60px); } }

/* -------------------------------------------------------------- */
/* SEARCH BAR                                                      */
/* -------------------------------------------------------------- */
.search-bar { position: relative; }
.search-bar .s-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search-bar input {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  padding: 9px 16px 9px 38px;
  color: var(--text-dark);
  font-size: 0.875rem;
  font-family: var(--font-body);
  font-weight: 500;
  outline: none;
  transition: var(--t-fast);
}
.search-bar input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,58,143,0.08); }
.search-bar input::placeholder { color: var(--text-subtle); font-weight: 400; }

/* -------------------------------------------------------------- */
/* TABS                                                            */
/* -------------------------------------------------------------- */
.tabs {
  display: flex; gap: var(--s-xs);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 4px;
  width: fit-content;
}
.tab-btn {
  padding: 7px 18px;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--t-normal);
  font-family: var(--font-body);
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--white);
  color: var(--blue);
  box-shadow: var(--shadow-sm);
}
.tab-btn:not(.active):hover { color: var(--text-dark); }

/* -------------------------------------------------------------- */
/* PAGE LAYOUT HELPERS                                             */
/* -------------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--s-xl);
  gap: var(--s-lg); flex-wrap: wrap;
}
.page-title { margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }

.section-label {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: var(--s-md);
  display: flex; align-items: center; gap: var(--s-xs);
}

.divider { height: 1px; background: var(--border); margin: var(--s-xl) 0; }

/* Grid */
.grid-4  { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s-md); }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--s-lg); }
.grid-2  { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--s-lg); }
.grid-stat { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s-md); }

/* Lesson layout */
.lesson-cols {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--s-xl);
  align-items: start;
}
.lesson-sticky { position: sticky; top: calc(var(--topbar-h) + var(--s-lg)); }

/* -------------------------------------------------------------- */
/* LESSON CONTENT                                                  */
/* -------------------------------------------------------------- */
.lesson-content {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-body);
  line-height: 1.85;
}
.lesson-content h1,.lesson-content h2,.lesson-content h3 {
  font-family: var(--font-heading);
  color: var(--text-dark);
  margin: var(--s-lg) 0 var(--s-sm);
}
.lesson-content p { margin-bottom: var(--s-md); }
.lesson-content strong { color: var(--text-dark); font-weight: 700; }
.lesson-content em { color: var(--blue-mid); font-style: normal; font-weight: 600; }
.lesson-content ul,.lesson-content ol {
  margin: var(--s-xs) 0 var(--s-md) var(--s-lg);
  list-style: revert;
}
.lesson-content li { margin-bottom: 4px; }
.lesson-content code {
  background: var(--blue-pale);
  border: 1px solid rgba(26,58,143,0.1);
  border-radius: var(--r-xs);
  padding: 2px 7px;
  font-family: monospace;
  font-size: 0.88em;
  color: var(--blue);
}
.lesson-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-md);
  overflow-x: auto;
  margin-bottom: var(--s-md);
}
.lesson-content pre code {
  background: none; border: none; padding: 0;
  color: var(--text-dark); font-size: 0.9rem;
}

/* -------------------------------------------------------------- */
/* EMPTY STATE                                                     */
/* -------------------------------------------------------------- */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--s-2xl); text-align: center; gap: var(--s-md);
}
.empty-icon { font-size: 2.5rem; opacity: 0.6; }
.empty-title { font-weight: 700; color: var(--text-body); font-family: var(--font-heading); }
.empty-desc { font-size: 0.875rem; color: var(--text-muted); max-width: 300px; }

/* -------------------------------------------------------------- */
/* TREE VIEW (Admin)                                               */
/* -------------------------------------------------------------- */
.tree-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--s-md);
}
.tree-sem-head {
  display: flex; align-items: center; gap: var(--s-md);
  padding: var(--s-md) var(--s-lg);
  background: var(--blue-pale);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--t-fast);
}
.tree-sem-head:hover { background: #D9E9FF; }
.tree-sem-name { flex: 1; font-family: var(--font-heading); font-weight: 800; font-size: 0.95rem; color: var(--blue); }
.tree-sem-meta { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.tree-sub-row {
  border-bottom: 1px solid var(--border);
}
.tree-sub-row:last-child { border-bottom: none; }
.tree-sub-head {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: 10px var(--s-lg);
  cursor: pointer; transition: var(--t-fast);
}
.tree-sub-head:hover { background: var(--bg-hover); }
.sub-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tree-sub-name { flex: 1; font-weight: 700; font-size: 0.87rem; color: var(--text-dark); }

.tree-ch-list {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease;
}
.tree-ch-list.open { max-height: 9999px; }

.tree-ch-row {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: 8px var(--s-lg) 8px 52px;
  border-bottom: 1px solid var(--border);
  transition: var(--t-fast);
}
.tree-ch-row:last-child { border-bottom: none; }
.tree-ch-row:hover { background: var(--bg-hover); }
.ch-badge {
  width: 24px; height: 24px;
  background: var(--blue);
  color: white;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 800; flex-shrink: 0;
  font-family: var(--font-heading);
}
.ch-label { flex: 1; font-size: 0.84rem; font-weight: 600; color: var(--text-body); }
.ch-meta  { font-size: 0.72rem; color: var(--text-subtle); font-weight: 600; }

/* -------------------------------------------------------------- */
/* LOGIN PAGE                                                      */
/* -------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
}
.login-left {
  flex: 1;
  background: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-2xl);
  position: relative;
  overflow: hidden;
}
.login-left-deco {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.login-right {
  width: 480px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-2xl);
  box-shadow: -10px 0 40px rgba(0,0,0,0.08);
}
.login-form-wrap { width: 100%; max-width: 360px; }
.login-error-box {
  background: #FEF2F2;
  border: 1.5px solid #FECACA;
  border-radius: var(--r-md);
  padding: 11px 14px;
  display: none;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-md);
  color: var(--red);
  font-size: 0.875rem;
  font-weight: 600;
}
.login-error-box.show { display: flex; animation: shake 0.4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%,75%  { transform: translateX(-6px); }
  50%      { transform: translateX(6px); }
}
.pass-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--text-subtle); }
.pass-toggle:hover { color: var(--text-dark); }

/* -------------------------------------------------------------- */
/* UTILITIES                                                       */
/* -------------------------------------------------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--s-xs); }
.gap-sm { gap: var(--s-sm); }
.gap-md { gap: var(--s-md); }
.gap-lg { gap: var(--s-lg); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.relative { position: relative; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-blue   { color: var(--blue); }
.text-amber  { color: var(--amber-dark); }
.text-muted  { color: var(--text-muted); }
.text-dark   { color: var(--text-dark); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mb-sm { margin-bottom: var(--s-sm); }
.mb-md { margin-bottom: var(--s-md); }
.mb-lg { margin-bottom: var(--s-lg); }
.mb-xl { margin-bottom: var(--s-xl); }
.mt-sm { margin-top: var(--s-sm); }
.mt-md { margin-top: var(--s-md); }
.mt-lg { margin-top: var(--s-lg); }
.spin { animation: spinA 0.7s linear infinite; }
@keyframes spinA { to { transform: rotate(360deg); } }
.spinner-sm { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; }

/* -------------------------------------------------------------- */
/* ANIMATIONS                                                      */
/* -------------------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.45s ease forwards; }
.d1 { animation-delay: 0.05s; opacity:0; }
.d2 { animation-delay: 0.1s; opacity:0; }
.d3 { animation-delay: 0.15s; opacity:0; }
.d4 { animation-delay: 0.2s; opacity:0; }
.d5 { animation-delay: 0.25s; opacity:0; }

/* -------------------------------------------------------------- */
/* RESPONSIVE / MOBILE                                             */
/* -------------------------------------------------------------- */
@media (max-width: 1100px) {
  .lesson-cols { grid-template-columns: 1fr; }
  .lesson-sticky { position: static; }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-stat { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 900px) {
  /* Sidebar becomes a drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .sidebar-overlay.mobile-open { display: block; }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .topbar { padding: 0 var(--s-md); }
  .page-wrapper { padding: var(--s-md); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .login-left { display: none; }
  .login-right { width: 100%; padding: var(--s-xl) var(--s-lg); }
}

@media (max-width: 600px) {
  .grid-4,.grid-3,.grid-2,.grid-stat { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .tabs { overflow-x: auto; }
  .topbar-right .btn span { display: none; }
  .breadcrumb { overflow-x: auto; white-space: nowrap; }
  .admin-grid { grid-template-columns: 1fr; }
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; }
  .lesson-cols { grid-template-columns: 1fr; }
}

/* Icon picker */
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-opt {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; cursor: pointer;
  background: var(--bg); border: 1.5px solid var(--border);
  transition: var(--t-fast);
}
.icon-opt.sel { border-color: var(--blue); background: var(--blue-pale); }
.icon-opt:hover { background: var(--blue-pale); border-color: var(--blue); }

.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.color-opt {
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: var(--t-fast);
}
.color-opt.sel { border-color: var(--text-dark); transform: scale(1.15); }
