/* CF-LMS — Minimal neutral design system (Notion/Stripe feel) */

:root {
  /* Neutral palette — light */
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --fg: #18181b;
  --fg-soft: #3f3f46;
  --muted: #71717a;
  --border: #ececec;
  --border-strong: #d4d4d8;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --brand-a: #7c3aed;
  --brand-b: #2563eb;
  --grad: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  --success: #16a34a;
  --danger: #dc2626;
  --ring: rgba(109, 81, 234, 0.28);
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, 0.05);
  --shadow-md: 0 6px 24px -8px rgba(76, 56, 200, 0.18);

  /* Spacing scale (4px base) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Radius */
  --r-sm: 6px; --r: 8px; --r-lg: 12px;

  /* Type scale */
  --fs-xs: 0.8125rem; --fs-sm: 0.875rem; --fs-base: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.875rem; --fs-3xl: 2.375rem;

  --maxw: 1080px;
  --maxw-narrow: 720px;
  --t: 130ms ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --fg: #ededed;
    --fg-soft: #c4c4c8;
    --muted: #8e8e96;
    --border: #232327;
    --border-strong: #34343a;
    --accent: #60a5fa;
    --accent-fg: #0b0b0c;
    --brand-a: #a78bfa;
    --brand-b: #60a5fa;
    --success: #4ade80;
    --danger: #f87171;
    --ring: rgba(139, 122, 246, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px -8px rgba(124, 100, 250, 0.25);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t); }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; font-weight: 650; color: var(--fg); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s5); }

main.container { padding-top: var(--s7); padding-bottom: var(--s8); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--fg); font-size: var(--fs-base); letter-spacing: -0.02em;
}
.logo:hover { text-decoration: none; }
.logo-mark { flex: none; border-radius: 8px; transition: transform var(--t); }
.logo:hover .logo-mark { transform: rotate(-6deg) scale(1.05); }
.logo-text { font-weight: 600; }
.logo-text strong { font-weight: 700; }
.logo-dim { color: var(--muted); font-weight: 500; }
.nav { display: flex; align-items: center; gap: var(--s5); }
.nav a { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.nav a:hover { color: var(--fg); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { margin: var(--s6) 0 var(--s8); max-width: 640px; }
.hero h1 { font-size: var(--fs-3xl); margin-bottom: var(--s3); }
.hero p { color: var(--muted); font-size: var(--fs-lg); }
.hero-badge {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em;
  color: var(--brand-a); background: color-mix(in srgb, var(--brand-a) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-a) 22%, transparent);
  border-radius: 999px; padding: 4px 12px; margin-bottom: var(--s4);
}
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 550;
  line-height: 1; cursor: pointer; white-space: nowrap;
  padding: 10px 16px; border-radius: var(--r);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg);
  transition: background var(--t), border-color var(--t), opacity var(--t), transform var(--t);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.btn-primary {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { opacity: 0.92; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary { background: var(--surface); color: var(--fg); }

.btn-sm { padding: 6px 11px; font-size: var(--fs-xs); }

.btn-danger-sm {
  padding: 6px 11px; font-size: var(--fs-xs);
  background: transparent; color: var(--danger); border-color: var(--border-strong);
}
.btn-danger-sm:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }

.btn-icon {
  padding: 5px 9px; font-size: var(--fs-sm); line-height: 1;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--r-sm);
}
.btn-icon:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }

.btn-link {
  background: none; border: none; color: var(--accent); padding: 0;
  font-size: var(--fs-sm); cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

.btn-back {
  display: inline-flex; align-items: center; gap: var(--s1);
  color: var(--muted); font-size: var(--fs-sm); font-weight: 500;
  margin-bottom: var(--s5);
}
.btn-back:hover { color: var(--fg); text-decoration: none; }

/* ---------- Cards / course grid ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  transition: border-color var(--t), transform var(--t);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s4);
}
.course-card h3 { margin-bottom: var(--s2); }
.course-card h3 a { color: var(--fg); }
.course-card h3 a:hover { color: var(--accent); text-decoration: none; }
.course-card .desc { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s4); }
.course-card:hover {
  border-color: color-mix(in srgb, var(--brand-a) 35%, var(--border));
  transform: translateY(-3px); box-shadow: var(--shadow-md);
}
.course-card .progress-wrapper { margin-top: var(--s4); }

/* ---------- Auth ---------- */
.auth-page {
  max-width: 420px; margin: var(--s8) auto 0; text-align: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s6) var(--s5);
  box-shadow: var(--shadow-sm);
}
.auth-page h1 { margin-bottom: var(--s2); }
.auth-page > p { color: var(--muted); margin-bottom: var(--s5); }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: var(--s4); }
.auth-form .btn { width: 100%; }

/* ---------- Forms ---------- */
.form-field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.form-field label { font-size: var(--fs-sm); font-weight: 550; color: var(--fg-soft); }
.form-field input[type='text'],
.form-field input[type='email'],
.form-field input[type='number'],
.form-field input[type='password'],
.form-field input:not([type]),
.form-field textarea,
.form-field select {
  width: 100%; font-family: inherit; font-size: var(--fs-sm); color: var(--fg);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 10px 12px;
  transition: border-color var(--t), box-shadow var(--t);
}
.form-field textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
.form-field input::placeholder, .form-field textarea::placeholder { color: var(--muted); }
.required { color: var(--danger); margin-left: 2px; }

.checkbox-field label {
  flex-direction: row; align-items: center; gap: var(--s2);
  display: flex; cursor: pointer; font-weight: 500; color: var(--fg);
}
.checkbox-field input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.inline-form { display: inline; }

/* ---------- Course outline / lessons ---------- */
.outline { display: flex; flex-direction: column; gap: var(--s5); margin-top: var(--s5); }
.module {
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.module-title {
  font-size: var(--fs-sm); font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  padding: var(--s3) var(--s4); background: var(--surface);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
}
.lesson-list { list-style: none; }
.lesson-item { border-bottom: 1px solid var(--border); }
.lesson-item:last-child { border-bottom: none; }
.lesson-item.current {
  background: color-mix(in srgb, var(--brand-a) 7%, transparent);
  box-shadow: inset 3px 0 0 0 var(--brand-a);
}
.lesson-link {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); color: var(--fg); font-size: var(--fs-sm);
  transition: background var(--t);
}
a.lesson-link:hover { background: var(--surface); text-decoration: none; color: var(--accent); }
.lesson-item.locked .lesson-link, .locked-text { color: var(--muted); cursor: default; }
.lock-icon { font-size: var(--fs-xs); opacity: 0.7; }
.check { color: var(--success); font-weight: 700; }

/* ---------- Lesson page ---------- */
.lesson-title { margin-bottom: var(--s5); }
.player-section {
  background: #000; border-radius: var(--r-lg); overflow: hidden;
  margin-bottom: var(--s5); aspect-ratio: 16 / 9;
}
.player-section video { width: 100%; height: 100%; display: block; }
.video-error {
  display: flex; align-items: center; justify-content: center; height: 100%;
  color: #fff; font-size: var(--fs-sm); padding: var(--s5); text-align: center;
}
.lesson-content {
  max-width: var(--maxw-narrow); font-size: var(--fs-base); color: var(--fg-soft);
}
.lesson-content > * + * { margin-top: var(--s4); }
.lesson-content h2, .lesson-content h3 { color: var(--fg); margin-top: var(--s6); }
.lesson-content ul, .lesson-content ol { padding-left: var(--s5); }
.lesson-content li + li { margin-top: var(--s1); }
.lesson-content code {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-sm);
}
.lesson-content pre {
  background: var(--surface-2); padding: var(--s4); border-radius: var(--r);
  overflow-x: auto; border: 1px solid var(--border);
}
.lesson-content pre code { background: none; padding: 0; }
.lesson-content blockquote {
  border-left: 3px solid var(--border-strong); padding-left: var(--s4); color: var(--muted);
}
.lesson-content img { max-width: 100%; border-radius: var(--r); }
.lesson-content hr { border: none; border-top: 1px solid var(--border); margin: var(--s5) 0; }

.lesson-nav, .lesson-navigation {
  display: flex; justify-content: space-between; gap: var(--s3);
  margin-top: var(--s7); padding-top: var(--s5); border-top: 1px solid var(--border);
}

/* ---------- Progress ---------- */
.progress-wrapper { display: flex; flex-direction: column; gap: var(--s1); }
.progress-bar {
  position: relative; height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; flex: 1;
}
.progress-fill { height: 100%; background: var(--grad); border-radius: 999px; transition: width var(--t); }
.progress-text { font-size: var(--fs-xs); color: var(--muted); }
.course-progress { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0; }

/* ---------- Attachments ---------- */
.attachments { margin-top: var(--s6); }
.attachments h3 { font-size: var(--fs-base); margin-bottom: var(--s3); }
.attachment-list, .attachment-admin-list { list-style: none; display: flex; flex-direction: column; gap: var(--s1); }
.attachment-list li, .attachment-admin-list li {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); font-size: var(--fs-sm);
}
.attachment-list li::before { content: '↓'; color: var(--muted); }
.file-size { color: var(--muted); font-size: var(--fs-xs); }

/* ---------- Admin ---------- */
.admin-dashboard, .admin-section { margin-bottom: var(--s6); }
.admin-section {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5);
  background: var(--bg); box-shadow: var(--shadow-sm); overflow-x: auto;
}
.admin-section h2 {
  font-size: var(--fs-lg); margin-bottom: var(--s4);
  display: flex; align-items: center; gap: var(--s2);
}
.admin-section h2::before {
  content: ''; width: 4px; height: 1em; border-radius: 2px;
  background: var(--grad); flex: none;
}
.admin-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s3); }
.admin-links a {
  display: block; padding: var(--s4); border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface); color: var(--fg); font-weight: 550;
  transition: border-color var(--t), background var(--t);
}
.admin-links a:hover {
  border-color: color-mix(in srgb, var(--brand-a) 35%, var(--border));
  background: var(--surface-2); text-decoration: none;
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.admin-form { max-width: var(--maxw-narrow); }
.admin-form .btn { margin-top: var(--s2); }

.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: var(--s3) var(--s3); border-bottom: 1px solid var(--border-strong);
}
.admin-table td { padding: var(--s3) var(--s3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover td { background: var(--surface); }
.admin-table .actions { display: flex; gap: var(--s2); }

.module-admin {
  border: 1px solid var(--border); border-radius: var(--r); padding: var(--s4);
  margin-bottom: var(--s3);
}
.module-admin .module-title { background: none; border: none; padding: 0 0 var(--s3); }
.module-actions, .lesson-actions { display: flex; gap: var(--s2); align-items: center; }
.lesson-admin-list { list-style: none; display: flex; flex-direction: column; gap: var(--s1); }
.lesson-admin-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: var(--fs-sm);
}
.add-module, .search-form { display: flex; gap: var(--s2); margin-top: var(--s4); }
.search-input, .search-form input { flex: 1; max-width: 360px; }
.webhook-log { font-family: var(--mono); font-size: var(--fs-xs); }

/* ---------- States / misc ---------- */
.empty-state { text-align: center; color: var(--muted); padding: var(--s7) var(--s4); font-size: var(--fs-sm); }
.error, .success {
  padding: var(--s3) var(--s4); border-radius: var(--r); font-size: var(--fs-sm);
  margin-bottom: var(--s4); border: 1px solid;
}
.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.success { color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.purchase-note { color: var(--muted); font-size: var(--fs-sm); margin: var(--s4) 0; }
.breadcrumb { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s4); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--fg); }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: var(--s8) var(--s4); }
.error-page h1 {
  font-size: clamp(3rem, 12vw, 6rem); line-height: 1; margin-bottom: var(--s3);
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.error-page p { color: var(--muted); margin-bottom: var(--s5); }

/* ---------- Lesson completion ---------- */
.lesson-complete-form { margin-top: var(--s6); }
.lesson-completed {
  margin-top: var(--s6); color: var(--success); font-weight: 550; font-size: var(--fs-sm);
}

/* Utilities */
.text-center { text-align: center; }
.mt-1 { margin-top: var(--s3); } .mt-2 { margin-top: var(--s5); }
.mb-1 { margin-bottom: var(--s3); } .mb-2 { margin-bottom: var(--s5); }

@media (max-width: 640px) {
  .container { padding: 0 var(--s4); }
  main.container { padding-top: var(--s5); }
  .hero { margin: var(--s4) 0 var(--s6); }
  .hero h1 { font-size: var(--fs-2xl); }
  .nav { gap: var(--s4); }
  .lesson-nav, .lesson-navigation { flex-direction: column; }
  .lesson-nav .btn, .lesson-navigation .btn { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }
  .admin-table { min-width: 560px; }
  .auth-page { padding: var(--s5) var(--s4); }
}
