/* =========================================================================
   Design tokens
   -------------------------------------------------------------------------
   Brand palette (as given): primary #2563EB, plus #F8FAFC, #FFFFFF,
   #3B82F6, #0F172A. Values are stored as HSL triplets (no "hsl()" wrapper)
   so utility classes below can apply opacity with hsl(var(--x) / <alpha>).

   A handful of neutral/semantic tokens (muted surfaces, borders, and
   success/warning/danger) are derived from the same slate/blue family to
   support normal UI states (disabled fields, dividers, form validation)
   that the 5-color brief didn't specify. They are isolated here so they're
   easy to find and change.
   ========================================================================= */
:root {
  --background: 210 40% 98%;        /* #F8FAFC */
  --foreground: 222 47% 11%;        /* #0F172A */

  --card: 0 0% 100%;                /* #FFFFFF */
  --card-foreground: 222 47% 11%;   /* #0F172A */

  --popover: 0 0% 100%;
  --popover-foreground: 222 47% 11%;

  --primary: 221 83% 53%;           /* #2563EB */
  --primary-foreground: 0 0% 100%;

  --secondary: 217 91% 60%;         /* #3B82F6, used as accent/secondary */
  --secondary-foreground: 0 0% 100%;

  --accent: 217 91% 60%;            /* #3B82F6 */
  --accent-foreground: 0 0% 100%;

  /* --- derived neutrals (not part of the 5-color brief, needed for UI states) --- */
  --muted: 210 40% 95%;
  --muted-foreground: 215 16% 47%;
  --border: 214 32% 89%;
  --input: 214 32% 89%;
  --ring: 221 83% 53%;

  --success: 142 76% 36%;
  --success-foreground: 0 0% 100%;
  --warning: 38 92% 50%;
  --warning-foreground: 222 47% 11%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;

  --radius: 0.75rem;

  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* =========================================================================
   Base
   ========================================================================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  line-height: 1.25;
  color: hsl(var(--foreground));
}
p { margin: 0 0 0.75rem 0; }
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
::selection { background: hsl(var(--primary) / 0.25); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   Theme token utility classes
   (hand-authored to exactly match the classes tailwind.config.js maps to
   these same CSS variables -- see that file to wire up a real Tailwind
   build later with zero class-name changes)
   ========================================================================= */

/* --- color: background --- */
.bg-background { background-color: hsl(var(--background)); }
.bg-card { background-color: hsl(var(--card)); }
.bg-primary { background-color: hsl(var(--primary)); }
.bg-primary\/10 { background-color: hsl(var(--primary) / 0.1); }
.bg-primary\/90 { background-color: hsl(var(--primary) / 0.9); }
.bg-secondary { background-color: hsl(var(--secondary)); }
.bg-accent { background-color: hsl(var(--accent)); }
.bg-accent\/10 { background-color: hsl(var(--accent) / 0.1); }
.bg-muted { background-color: hsl(var(--muted)); }
.bg-success { background-color: hsl(var(--success)); }
.bg-success\/10 { background-color: hsl(var(--success) / 0.1); }
.bg-warning { background-color: hsl(var(--warning)); }
.bg-warning\/10 { background-color: hsl(var(--warning) / 0.1); }
.bg-destructive { background-color: hsl(var(--destructive)); }
.bg-destructive\/10 { background-color: hsl(var(--destructive) / 0.1); }
.bg-white { background-color: #fff; }
.bg-transparent { background-color: transparent; }

/* --- color: text --- */
.text-foreground { color: hsl(var(--foreground)); }
.text-card-foreground { color: hsl(var(--card-foreground)); }
.text-primary { color: hsl(var(--primary)); }
.text-primary-foreground { color: hsl(var(--primary-foreground)); }
.text-secondary { color: hsl(var(--secondary)); }
.text-accent { color: hsl(var(--accent)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-success { color: hsl(var(--success)); }
.text-warning { color: hsl(var(--warning)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-white { color: #fff; }

/* --- color: border --- */
.border-border { border-color: hsl(var(--border)); }
.border-primary { border-color: hsl(var(--primary)); }
.border-accent { border-color: hsl(var(--accent)); }
.border-success { border-color: hsl(var(--success)); }
.border-destructive { border-color: hsl(var(--destructive)); }
.border-transparent { border-color: transparent; }

/* --- hover variants (curated set actually used in this app) --- */
.hover\:bg-primary\/90:hover { background-color: hsl(var(--primary) / 0.9); }
.hover\:bg-muted:hover { background-color: hsl(var(--muted)); }
.hover\:bg-accent\/10:hover { background-color: hsl(var(--accent) / 0.1); }
.hover\:bg-destructive\/10:hover { background-color: hsl(var(--destructive) / 0.1); }
.hover\:text-primary:hover { color: hsl(var(--primary)); }
.hover\:underline:hover { text-decoration: underline; }
.hover\:border-primary:hover { border-color: hsl(var(--primary)); }

/* =========================================================================
   Layout utilities
   ========================================================================= */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.self-start { align-self: flex-start; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.max-w-xs { max-width: 20rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-6xl { max-width: 72rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* spacing */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-2 { padding-bottom: 0.5rem; }

.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-auto { margin-left: auto; }

/* typography */
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.italic { font-style: italic; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.025em; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.leading-tight { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.list-none { list-style: none; padding: 0; margin: 0; }

/* borders / radius / shadow */
.border { border-width: 1px; border-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; }
.border-2 { border-width: 2px; border-style: solid; }
.rounded { border-radius: 0.375rem; }
.rounded-md { border-radius: 0.5rem; }
.rounded-lg { border-radius: var(--radius); }
.rounded-xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.shadow-sm { box-shadow: 0 1px 2px 0 rgb(15 23 42 / 0.05); }
.shadow-md { box-shadow: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06); }
.shadow-lg { box-shadow: 0 10px 30px -5px rgb(15 23 42 / 0.12), 0 4px 8px -4px rgb(15 23 42 / 0.08); }

.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.select-none { user-select: none; }
.transition { transition: all 0.15s ease; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.pointer-events-none { pointer-events: none; }

/* =========================================================================
   Component classes
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover:not(:disabled) { background: hsl(var(--primary) / 0.9); }
.btn-secondary { background: hsl(var(--accent) / 0.12); color: hsl(var(--primary)); }
.btn-secondary:hover:not(:disabled) { background: hsl(var(--accent) / 0.2); }
.btn-outline { background: transparent; color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--muted)); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--muted)); }
.btn-danger { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-danger:hover:not(:disabled) { background: hsl(var(--destructive) / 0.88); }
.btn-block { width: 100%; }

.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.input, select.input, textarea.input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.5rem;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15); }
.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.35rem;
}
.field { margin-bottom: 1rem; }
.help-text { font-size: 0.8rem; color: hsl(var(--muted-foreground)); margin-top: 0.3rem; }
.error-text { font-size: 0.8rem; color: hsl(var(--destructive)); margin-top: 0.3rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-primary { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }
.badge-success { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); }
.badge-warning { background: hsl(var(--warning) / 0.15); color: #92620a; }
.badge-muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge-destructive { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); }

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: hsl(var(--muted-foreground)); font-weight: 700; padding: 0.6rem 0.9rem; border-bottom: 1px solid hsl(var(--border)); }
.table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: hsl(var(--muted) / 0.5); }

.progress-track { width: 100%; height: 0.5rem; background: hsl(var(--muted)); border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background: hsl(var(--primary)); border-radius: 9999px; transition: width 0.3s ease; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 9999px;
  background: hsl(var(--primary) / 0.12); color: hsl(var(--primary));
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 100;
  padding: 0.75rem 1.1rem; border-radius: 0.6rem; font-size: 0.875rem; font-weight: 500;
  box-shadow: 0 10px 30px -5px rgb(15 23 42 / 0.2);
  max-width: 24rem;
}
.toast-success { background: hsl(var(--success)); color: #fff; }
.toast-error { background: hsl(var(--destructive)); color: #fff; }

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: hsl(var(--foreground));
  border-radius: var(--radius);
  overflow: hidden;
}
.video-frame video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.5rem;
  background: hsl(var(--foreground) / 0.85); color: #fff; text-align: center; padding: 1.5rem;
}

/* rendered custom pages (built in the admin Pages editor) */
.page-content { line-height: 1.7; }
.page-content h1, .page-content h2, .page-content h3 { margin-top: 1.5rem; }
.page-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.page-content ul, .page-content ol { padding-left: 1.4rem; margin: 0.5rem 0 1rem; }
.page-content a { color: hsl(var(--primary)); text-decoration: underline; }
.page-content p { margin: 0 0 0.9rem; }

/* app shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border)); padding: 1.25rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.75rem; border-radius: 0.5rem;
  color: hsl(var(--muted-foreground)); font-weight: 500; font-size: 0.875rem;
  cursor: pointer; transition: all 0.15s ease;
}
.sidebar-link:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); text-decoration: none; }
.sidebar-link.active { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.main-content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.75rem; border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.page { padding: 1.75rem; max-width: 1200px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .page { padding: 1.1rem; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}
