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

/* ═══════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════ */
:root {
  /* Green Palette */
  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-300: #86efac;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-800: #166534;
  --green-900: #14532d;

  /* Primary */
  --primary:        var(--green-500);
  --primary-dark:   var(--green-600);
  --primary-darker: var(--green-700);
  --primary-light:  var(--green-400);
  --primary-glow:   rgba(34, 197, 94, 0.25);

  /* Surface */
  --bg:          #0a0f0d;
  --surface-1:   #111815;
  --surface-2:   #1a2420;
  --surface-3:   #22302a;
  --surface-4:   #2d4038;
  --border:      rgba(34, 197, 94, 0.15);
  --border-soft: rgba(255,255,255,0.06);

  /* Text */
  --text-1: #f0fdf4;
  --text-2: #a7c4b0;
  --text-3: #637a6b;
  --text-inv: #0a0f0d;

  /* Status */
  --success: #22c55e;
  --warning: #f59e0b;
  --error:   #ef4444;
  --info:    #3b82f6;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 30px var(--primary-glow);

  /* Transitions */
  --t-fast:   150ms ease;
  --t-normal: 250ms ease;
  --t-slow:   400ms ease;

  /* Sidebar width */
  --sidebar-w: 260px;
}

/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-light); }

img { max-width: 100%; display: block; }

/* ═══════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-1);
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.1rem; }

.text-muted  { color: var(--text-2); }
.text-faint  { color: var(--text-3); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center !important; display: block; width: 100%; }
.text-right  { text-align: right !important; }
.d-block     { display: block !important; }
.w-full      { width: 100% !important; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ═══════════════════════════════════════
   LAYOUT
═══════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--t-normal);
}

@media (max-width: 1024px) {
  .main-content { margin-left: 0; }
}

.page-container {
  padding: var(--space-8);
  flex: 1;
}

.page-header {
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1500;
  transition: transform var(--t-normal);
  overflow-y: auto;
  transform: translateX(0);
}

/* Tablets (landscape/portrait) and under */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
}

/* Large Desktop - Default Open */
@media (min-width: 1025px) {
  .sidebar.collapsed { transform: translateX(-260px); }
  .sidebar.collapsed + .main-content { margin-left: 0; }
}

.sidebar-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1400;
}

.no-transition {
  transition: none !important;
}

.sidebar-brand {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow);
}

.sidebar-brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}
.sidebar-brand-sub {
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 500;
}

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

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: var(--space-5) var(--space-6) var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-6);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  margin: 2px var(--space-3);
  transition: all var(--t-fast);
  position: relative;
}
.sidebar-link:hover {
  color: var(--text-1);
  background: var(--surface-2);
}
.sidebar-link.active {
  color: var(--primary);
  background: rgba(34,197,94,0.06);
}
.sidebar-link.active .sidebar-icon {
  color: var(--primary);
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Sidebar Dropdown ── */
.sidebar-dropdown-trigger {
  width: calc(100% - (var(--space-3) * 2));
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.sidebar-chevron {
  font-size: 0.65rem;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform var(--t-normal);
  margin-left: auto;
}

.sidebar-submenu {
  overflow: hidden;
  position: relative;
  margin-left: 28px;
  border-left: 1px solid var(--border-soft);
  margin-bottom: 8px;
}

.sidebar-sublink {
  padding: 8px 16px;
  margin: 1px 8px;
  font-size: 0.825rem;
  color: var(--text-3);
}

.sidebar-sublink:hover {
  color: var(--text-1);
  background: var(--surface-2);
}

.sidebar-sublink.active {
  color: var(--primary);
  background: transparent;
  font-weight: 600;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--green-600), var(--green-800));
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 500;
}

/* ═══════════════════════════════════════
   TOPBAR
═══════════════════════════════════════ */
.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ═══════════════════════════════════════
   CARDS
═══════════════════════════════════════ */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: var(--space-6);
}

/* Stat cards */
.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: all var(--t-normal);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, var(--primary-glow), transparent 70%);
  pointer-events: none;
}
.stat-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: rgba(34,197,94,0.12);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Course cards (Poster 9:16 Style) */
.course-card {
  position: relative;
  aspect-ratio: 9/16;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--t-normal);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-decoration: none;
  color: inherit;
  z-index: 1;
}
.course-card:hover {
  border-color: var(--primary);
  transform: translateY(-6px);
  box-shadow: 0 10px 40px var(--primary-faint);
}

/* Lightsaber effect (Hover Flash) */
.course-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
  z-index: 3;
}
.course-card:hover::before {
  animation: flashHover 0.8s ease-in-out;
}
@keyframes flashHover {
  0%   { left: -100%; opacity: 0; }
  30%  { opacity: 1; }
  100% { left: 200%; opacity: 0; }
}

.course-thumb {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--surface-3);
  z-index: 1;
  transition: all var(--t-normal);
}

.course-thumb-placeholder {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  z-index: 1;
  transition: all var(--t-normal);
}

/* Blocked / Locked state */
.course-card.locked .course-thumb,
.course-card.locked .course-thumb-placeholder {
  filter: blur(8px) grayscale(60%);
  transform: scale(1.05); /* hide blurred edges */
}

.course-lock-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: rgba(255,255,255,0.6);
  z-index: 2;
  transition: all var(--t-normal);
}
.course-card:hover .course-lock-overlay {
  background: rgba(0,0,0,0.7);
  color: var(--primary);
  transform: scale(1.1);
}

.course-body {
  position: relative;
  z-index: 4;
  padding: var(--space-8) var(--space-5) var(--space-5);
  background: linear-gradient(to top, rgba(0,0,0,1) 10%, rgba(0,0,0,0.8) 60%, transparent);
  transform: translateY(100%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  width: 100%;
}
.course-card:hover .course-body {
  transform: translateY(0);
  opacity: 1;
}


.course-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.course-desc {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: var(--space-4);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

/* ═══════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════ */
.progress-wrap {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-3) 0;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green-500), var(--green-400));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
}

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--t-fast);
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: white;
  box-shadow: 0 4px 15px rgba(34,197,94,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--green-400), var(--green-500));
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(34,197,94,0.4);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border-soft);
}
.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ═══════════════════════════════════════
   BADGES
═══════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-green   { background: rgba(34,197,94,0.15);  color: var(--green-400); }
.badge-red     { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-yellow  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-blue    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-purple  { background: rgba(168,85,247,0.15); color: #c084fc; }
.badge-gray    { background: var(--surface-3);      color: var(--text-3); }

/* ═══════════════════════════════════════
   FORMS
═══════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}

.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--t-fast);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder { color: var(--text-3); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Switcher */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-3);
  transition: var(--t-normal);
  border-radius: 20px;
  border: 1px solid var(--border-soft);
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-3);
  transition: var(--t-normal);
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
  background-color: white;
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-3);
}

/* ═══════════════════════════════════════
   TABLES
═══════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-4) var(--space-5);
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

tbody td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); color: var(--text-1); }

/* ═══════════════════════════════════════
   AUTH PAGES
═══════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 50%, rgba(34,197,94,0.06) 0%, transparent 70%),
              var(--bg);
  padding: var(--space-6);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  margin: 0 auto var(--space-4);
  box-shadow: var(--shadow-glow);
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.auth-sub {
  color: var(--text-3);
  font-size: 0.9rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-divider {
  text-align: center;
  color: var(--text-3);
  font-size: 0.8rem;
  margin: var(--space-4) 0;
  position: relative;
}
.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: var(--border-soft);
}
.auth-divider span {
  background: var(--surface-1);
  padding: 0 var(--space-3);
  position: relative;
}

/* ═══════════════════════════════════════
   ALERT / TOAST
═══════════════════════════════════════ */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.alert-success { background: rgba(34,197,94,0.12);  border: 1px solid rgba(34,197,94,0.25);  color: var(--green-300); }
.alert-error   { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.25);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25); color: #fde68a; }
.alert-info    { background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.25); color: #93c5fd; }

.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  pointer-events: all;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: slideInRight 0.3s ease;
}

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

/* ═══════════════════════════════════════
   MODAL
═══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ═══════════════════════════════════════
   PLAYER
═══════════════════════════════════════ */
.player-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-container {
  width: 100%;
  background: #000;
  aspect-ratio: 16/9;
  position: relative;
}
.video-container iframe,
.video-container video {
  width: 100%;
  height: 100%;
  border: none;
}

.player-content {
  padding: var(--space-8);
}

.player-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-left: 1px solid var(--border-soft);
  overflow-y: auto;
  max-height: calc(100vh - 57px);
  position: sticky;
  top: 57px;
}

.player-sidebar-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

.module-group { border-bottom: 1px solid var(--border-soft); }

.module-toggle {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: none;
  border: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  transition: background var(--t-fast);
}
.module-toggle:hover { background: var(--surface-2); }

.lesson-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6) var(--space-3) var(--space-8);
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.85rem;
  transition: all var(--t-fast);
  border-left: 3px solid transparent;
}
.lesson-item:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
.lesson-item.active {
  background: rgba(34,197,94,0.08);
  color: var(--primary);
  border-left-color: var(--primary);
}
.lesson-item.completed { color: var(--text-3); }
.lesson-item.completed .lesson-check { color: var(--primary); }

.lesson-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  flex-shrink: 0;
  color: transparent;
  transition: all var(--t-fast);
}
.lesson-item.completed .lesson-check {
  background: rgba(34,197,94,0.15);
  border-color: var(--primary);
  color: var(--primary);
}

/* ═══════════════════════════════════════
   WEBHOOK LOG
═══════════════════════════════════════ */
.webhook-source-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.webhook-url-box {
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--primary);
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.event-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-processed { background: var(--success); }
.dot-pending   { background: var(--warning); animation: pulse 1.5s infinite; }
.dot-failed    { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ═══════════════════════════════════════
   GRIDS
═══════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }

.grid-courses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-5);
}

/* ═══════════════════════════════════════
   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-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-6  { padding: var(--space-6); }

.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: var(--radius-full); }

.hidden { display: none; }
.sr-only { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

/* ═══════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════ */
[x-cloak] { display: none !important; }

.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-out { animation: fadeOut 0.3s ease; }
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-darker); }

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .player-sidebar { width: 280px; }
}

@media (max-width: 768px) {
  /* Existing mobile rules refined above */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .player-layout { flex-direction: column; }
  .player-sidebar { width: 100%; position: static; max-height: none; }
  .page-container { padding: var(--space-5); }
  .auth-card { padding: var(--space-8) var(--space-6); }
}
/* Dropdown & Topbar User */
.topbar-user {
  position: relative;
  border-radius: var(--radius);
  padding: 4px 8px;
  transition: background var(--t-fast);
  cursor: pointer;
}
.topbar-user:hover {
  background: var(--surface-2);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
}

.dropdown-item {
  padding: 12px 16px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--t-fast);
  text-decoration: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.dropdown-item.text-red {
  color: var(--error);
}
.dropdown-item.text-red:hover {
  background: rgba(239,68,68,0.1);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
}
