/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem var(--space-6);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-body);
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast),
              transform var(--transition-fast);
  border: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn--accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn--accent:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--outline:hover {
  background: var(--color-primary);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-primary);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn--danger:hover { background: #b83a3a; border-color: #b83a3a; color: #fff; }

.btn--sm { padding: 0.4rem var(--space-4); font-size: var(--text-xs); }
.btn--lg { padding: 0.875rem var(--space-8); font-size: var(--text-base); }
.btn--icon { padding: 0.5rem; border-radius: var(--radius-md); }
.btn--full { width: 100%; }

.btn:disabled { opacity: 0.45; pointer-events: none; }


/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card--interactive {
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.card--interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.card--flat { box-shadow: none; }

.card__header { margin-bottom: var(--space-4); }
.card__title { font-size: var(--text-lg); font-weight: 600; }
.card__subtitle { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }
.card__body { }
.card__footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}


/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}

.badge--primary   { background: rgba(117,89,184,0.12); color: var(--color-primary-dark); }
.badge--accent    { background: rgba(90,131,217,0.12); color: var(--color-accent-hover); }
.badge--success   { background: rgba(61,170,110,0.12); color: #2a8057; }
.badge--warning   { background: rgba(217,145,42,0.12); color: #a86c15; }
.badge--danger    { background: rgba(217,79,79,0.12);  color: #b83a3a; }
.badge--neutral   { background: var(--color-surface-alt); color: var(--color-text-secondary); }
.badge--new       { background: var(--color-accent); color: #fff; }


/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,22,38,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--transition-base);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-overlay.is-open .modal { transform: translateY(0) scale(1); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.modal__title { font-size: var(--text-xl); font-weight: 600; }
.modal__close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  font-size: 1.25rem;
  border: none;
  background: none;
}
.modal__close:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.modal__body { padding: var(--space-6); }
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}


/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width var(--transition-base);
}

.sidebar__logo {
  padding: var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar__logo-text {
  font-family: var(--font-headline);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}

.sidebar__logo-text span { color: var(--color-accent); }

.sidebar__nav { padding: var(--space-4) 0; flex: 1; }

.sidebar__section-label {
  padding: var(--space-2) var(--space-4);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.625rem var(--space-4);
  margin: 2px var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  border: none;
  background: none;
  width: calc(100% - var(--space-4));
  text-align: left;
  font-family: inherit;
}

.sidebar__item i { font-size: 1.1rem; flex-shrink: 0; }

.sidebar__item:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-primary);
}

.sidebar__item--active {
  background: rgba(117,89,184,0.1);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar__item--active:hover {
  background: rgba(117,89,184,0.15);
  color: var(--color-primary);
}

.sidebar__footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__user-info { overflow: hidden; }
.sidebar__user-name { font-size: var(--text-sm); font-weight: 600; }
.sidebar__user-role { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Collapsed sidebar (1024px breakpoint) */
@media (max-width: 1024px) {
  .sidebar__logo-text,
  .sidebar__item span,
  .sidebar__section-label,
  .sidebar__user-info { display: none; }

  .sidebar__item { justify-content: center; padding: 0.75rem; width: auto; }
  .sidebar__logo { padding: var(--space-4); text-align: center; }
  .sidebar__footer { padding: var(--space-3); }
  .sidebar__user { justify-content: center; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
}


/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 6px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  width: calc(var(--progress, 0) * 1%);
  transition: width 0.5s ease;
}

.progress-bar--accent .progress-bar__fill { background: var(--color-accent); }
.progress-bar--success .progress-bar__fill { background: var(--color-success); }
.progress-bar--lg { height: 10px; }


/* ============================================================
   KPI CARD
   ============================================================ */
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.kpi-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(117,89,184,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-size: 1.3rem;
  margin-bottom: var(--space-4);
}

.kpi-card__value {
  font-family: var(--font-headline);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.kpi-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.kpi-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-2);
}

.kpi-card__trend--up { color: var(--color-success); }
.kpi-card__trend--down { color: var(--color-danger); }


/* ============================================================
   TIMELINE PIN (used in player + editor)
   ============================================================ */
.timeline-pin {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform var(--transition-elastic);
  color: var(--color-primary);
}

.timeline-pin:hover {
  transform: translateY(-50%) scale(1.4);
}

.timeline-pin--mcq { color: var(--color-primary); }
.timeline-pin--note { color: var(--color-accent); }

.timeline-pin__dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  background: currentColor;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: width var(--transition-elastic), height var(--transition-elastic);
}

.timeline-pin:hover .timeline-pin__dot { width: 16px; height: 16px; }

.timeline-pin__tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: #fff;
  font-size: var(--text-xs);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  max-width: 160px;
  white-space: normal;
  text-align: center;
}

.timeline-pin:hover .timeline-pin__tooltip { opacity: 1; }


/* ============================================================
   FORM GROUP
   ============================================================ */
.form-group { margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.input-group {
  display: flex;
  gap: 0;
}
.input-group input { border-radius: var(--radius-md) 0 0 var(--radius-md); border-right: none; }
.input-group .btn  { border-radius: 0 var(--radius-md) var(--radius-md) 0; flex-shrink: 0; }


/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

thead th:hover { color: var(--color-primary); }

thead th.sort-asc::after  { content: " ↑"; color: var(--color-primary); }
thead th.sort-desc::after { content: " ↓"; color: var(--color-primary); }

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-alt); }

tbody td {
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  vertical-align: middle;
}

tbody td.cell--primary { font-weight: 600; color: var(--color-text-primary); }


/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  color: var(--color-border);
  margin-bottom: var(--space-4);
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state__body { font-size: var(--text-sm); margin-bottom: var(--space-6); }


/* ============================================================
   ALERT / TOAST
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.alert--success { background: rgba(61,170,110,0.1); color: #2a8057; border: 1px solid rgba(61,170,110,0.3); }
.alert--danger  { background: rgba(217,79,79,0.1);  color: #b83a3a; border: 1px solid rgba(217,79,79,0.3); }
.alert--warning { background: rgba(217,145,42,0.1); color: #a86c15; border: 1px solid rgba(217,145,42,0.3); }
.alert--info    { background: rgba(117,89,184,0.1); color: var(--color-primary-dark); border: 1px solid rgba(117,89,184,0.2); }

/* Toast notification */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  background: var(--color-text-primary);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}


/* ============================================================
   TYPE TOGGLE (MCQ / Note selector)
   ============================================================ */
.type-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  width: fit-content;
}

.type-toggle__btn {
  padding: 0.4rem var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: inherit;
}

.type-toggle__btn--active {
  background: var(--color-primary);
  color: #fff;
}


/* ============================================================
   VIDEO CARD (teacher/student)
   ============================================================ */
.video-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.video-card__thumb {
  position: relative;
  padding-top: 56.25%; /* 16:9 */
  background: var(--color-surface-alt);
  overflow: hidden;
}

.video-card__thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card__thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 2rem;
}

.video-card__body { padding: var(--space-4); }
.video-card__title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.video-card__actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}


/* ============================================================
   CONCEPT GAP ROW (analytics)
   ============================================================ */
.concept-gap-row {
  border-left: 3px solid var(--color-warning) !important;
}
