/* ── Reset & variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #4f6ef7;
  --blue-dark:  #3b56d9;
  --blue-light: #eef1ff;
  --blue-glow:  rgba(79,110,247,.18);
  --text:       #0f172a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --green:      #059669;
  --red:        #dc2626;
  --radius:     14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09);
  --nav-h:      60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top nav ───────────────────────────────────────────────── */
.portal-nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center;
  padding: 0 24px; gap: 20px;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.nav-brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px var(--blue-glow);
}
.nav-brand-icon svg { width: 18px; height: 18px; fill: #fff; }
.nav-brand-name { font-size: .95rem; font-weight: 800; color: var(--text); }

.nav-links {
  display: flex; align-items: center; gap: 4px; margin-left: 8px;
}
.nav-link {
  padding: 7px 14px; border-radius: 8px;
  font-size: .84rem; font-weight: 600; color: var(--muted);
  text-decoration: none; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--blue-light); color: var(--blue); }

.nav-right {
  display: flex; align-items: center; gap: 12px; margin-left: auto;
}
.nav-user {
  display: flex; align-items: center; gap: 8px;
}
.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.nav-name { font-size: .82rem; font-weight: 600; color: var(--text); }

.btn-logout {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: .8rem; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: inherit;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: #fef2f2; }

/* Mobile hamburger (hidden on desktop) */
.nav-hamburger {
  display: none; background: none; border: none;
  cursor: pointer; padding: 6px; border-radius: 7px;
  color: var(--text); margin-right: 4px;
}
.nav-hamburger:hover { background: var(--bg); }

/* Mobile nav drawer */
.nav-mobile-menu {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  flex-direction: column;
}
.nav-mobile-menu.open { display: flex; }
.nav-mobile-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
}
.nav-mobile-panel {
  position: relative; z-index: 1;
  background: var(--card);
  width: 260px; height: 100%;
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-md);
  animation: slideInLeft .22s ease;
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
.nav-mobile-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.nav-mobile-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 9px;
  font-size: .875rem; font-weight: 600; color: var(--muted);
  text-decoration: none; transition: background .15s, color .15s;
}
.nav-mobile-link:hover { background: var(--bg); color: var(--text); }
.nav-mobile-link.active { background: var(--blue-light); color: var(--blue); }
.nav-mobile-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-mobile-bottom {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
}
.nav-mobile-user {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding: 8px 12px;
}
.nav-mobile-name { font-size: .83rem; font-weight: 600; color: var(--text); }
.nav-mobile-email { font-size: .72rem; color: var(--muted); }

/* ── Page wrapper ──────────────────────────────────────────── */
.portal-page { min-height: calc(100vh - var(--nav-h)); padding: 28px 24px 48px; max-width: 1100px; margin: 0 auto; }

/* ── Section header ────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.section-title { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.section-sub   { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: .875rem;
  margin-bottom: 20px; border: 1px solid transparent;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ── Stat pills ─────────────────────────────────────────────── */
.stat-pills { display: flex; gap: 14px; margin-bottom: 28px; flex-wrap: wrap; }
.s-pill {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 13px; padding: 16px 22px;
  box-shadow: var(--shadow-sm); min-width: 120px;
  position: relative; overflow: hidden;
}
.s-pill::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue), #7c3aed);
  border-radius: 13px 13px 0 0;
}
.s-pill.green::before { background: linear-gradient(90deg, #10b981, #059669); }
.s-pill.red::before   { background: linear-gradient(90deg, #f87171, #dc2626); }
.s-pill-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.s-pill-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.3px; }
.s-pill.green .s-pill-value { color: var(--green); }
.s-pill.red   .s-pill-value { color: var(--red); }

/* ── Course card grid ───────────────────────────────────────── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  text-decoration: none; color: inherit;
}
.course-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.course-thumb {
  width: 100%; aspect-ratio: 16/9;
  object-fit: cover; display: block;
  background: linear-gradient(135deg, #e0e7ff, #ddd6fe);
}
.course-thumb-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  display: flex; align-items: center; justify-content: center;
}
.course-thumb-placeholder svg { width: 44px; height: 44px; opacity: .4; }

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

.course-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cat-tag {
  background: var(--blue-light); color: var(--blue);
  border: 1px solid #c7d2fe; border-radius: 20px;
  padding: 3px 10px; font-size: .68rem; font-weight: 700;
}
.video-count { font-size: .72rem; color: var(--muted); }

.course-title {
  font-size: .95rem; font-weight: 700; color: var(--text);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.course-channel { font-size: .78rem; color: var(--muted); }

.course-footer {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* Badges */
.badge-access {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700;
}
.badge-active   { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-expired  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-locked   { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }

.days-chip {
  font-size: .72rem; font-weight: 700; color: #15803d;
  background: #f0fdf4; border: 1px solid #bbf7d0;
  padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}

.btn-view {
  padding: 7px 14px; border-radius: 8px;
  background: var(--blue); color: #fff;
  font-size: .78rem; font-weight: 700; text-decoration: none;
  transition: opacity .15s; white-space: nowrap;
}
.btn-view:hover { opacity: .88; }
.btn-locked {
  padding: 7px 14px; border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg); color: var(--muted);
  font-size: .78rem; font-weight: 600; text-decoration: none;
  white-space: nowrap; cursor: default;
}

/* ── Course detail ──────────────────────────────────────────── */
.course-detail-header {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  display: flex; gap: 24px; align-items: flex-start;
  box-shadow: var(--shadow-sm); margin-bottom: 24px;
}
.detail-thumb {
  width: 220px; border-radius: 10px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.detail-thumb-placeholder {
  width: 220px; aspect-ratio: 16/9; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  display: flex; align-items: center; justify-content: center;
}
.detail-info { flex: 1; min-width: 0; }
.detail-badges { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -.3px; }
.detail-channel { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.detail-desc { font-size: .84rem; line-height: 1.6; color: var(--text); margin-bottom: 14px; opacity: .85; }
.detail-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }

/* Access banner */
.access-banner {
  border-radius: var(--radius); padding: 14px 18px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 12px;
  font-size: .875rem; font-weight: 600;
}
.access-banner.active  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.access-banner.expired { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.access-banner.locked  { background: #fef9c3; border: 1px solid #fde68a; color: #92400e; }
.access-banner svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Lesson list */
.lessons-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.lesson-count-badge {
  background: var(--blue-light); color: var(--blue);
  border: 1px solid #c7d2fe; border-radius: 20px;
  padding: 2px 10px; font-size: .72rem; font-weight: 700;
}

.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 11px; padding: 14px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.lesson-card:hover { box-shadow: var(--shadow-md); border-color: #c7d2fe; }
.lesson-order {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  font-size: .72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lesson-thumb {
  width: 72px; height: 48px; object-fit: cover;
  border-radius: 7px; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.lesson-thumb-placeholder {
  width: 72px; height: 48px; border-radius: 7px; flex-shrink: 0;
  background: #f1f5f9; display: flex; align-items: center; justify-content: center;
}
.lesson-info { flex: 1; min-width: 0; }
.lesson-title { font-size: .875rem; font-weight: 600; color: var(--text);
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-dur   { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.yt-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 7px;
  background: #fef2f2; color: #ef4444; border: 1px solid #fecaca;
  font-size: .75rem; font-weight: 700; text-decoration: none;
  white-space: nowrap; transition: background .15s; flex-shrink: 0;
}
.yt-btn:hover { background: #fee2e2; }

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
}
.login-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.login-sub   { font-size: .83rem; color: var(--muted); margin-bottom: 28px; }

.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-field label { font-size: .8rem; font-weight: 600; color: var(--text); }
.form-field input {
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: .9rem; color: var(--text);
  background: #fff; outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }

.btn-login {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff; border: none; border-radius: 10px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  font-family: inherit; margin-top: 8px;
  box-shadow: 0 2px 10px var(--blue-glow);
  transition: opacity .15s;
}
.btn-login:hover { opacity: .9; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty-state svg { margin-bottom: 14px; opacity: .4; }
.empty-title { font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: .82rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-page { padding: 16px 16px 48px; }

  /* Nav: hide links, show hamburger */
  .nav-links, .nav-name { display: none; }
  .nav-hamburger { display: flex; align-items: center; justify-content: center; }

  /* Course detail: stack thumbnail */
  .course-detail-header { flex-direction: column; gap: 16px; }
  .detail-thumb,
  .detail-thumb-placeholder { width: 100%; max-width: 100%; aspect-ratio: 16/9; object-fit: cover; }

  /* Lesson card: hide thumbnail on very small */
  .lesson-thumb, .lesson-thumb-placeholder { display: none; }

  /* Stat pills wrap */
  .stat-pills { gap: 10px; }
  .s-pill { flex: 1; min-width: 100px; padding: 14px 16px; }

  /* Login card padding */
  .login-card { padding: 28px 20px; }

  /* Section header stack */
  .section-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .course-grid { grid-template-columns: 1fr; }
  .portal-nav { padding: 0 16px; }
}
