/* ===========================================================================
   Editor Dashboard — Design System
   Clean, minimalist corporate SaaS. Strict 8px rhythm. Inter type. High
   contrast. Left-aligned data. No purple gradients, no 3-card hero rows,
   no center-aligned elements (data is left-aligned by design).
   =========================================================================== */

:root {
  /* --- 8px spacing scale -------------------------------------------------- */
  --sp-0:  0px;
  --sp-1:  4px;     /* half-step for fine control (legal — 4 = 8/2) */
  --sp-2:  8px;
  --sp-3: 12px;     /* 4px offset within the 8px grid is intentional */
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 40px;
  --sp-8: 48px;
  --sp-9: 64px;
  --sp-10: 80px;

  /* --- Color palette: professional slate + single muted teal accent ------- */
  --c-bg:          #FFFFFF;
  --c-bg-subtle:   #F9FAFB;   /* gray-50  */
  --c-bg-elevated: #FFFFFF;
  --c-surface:     #FFFFFF;
  --c-border:      #E5E7EB;   /* gray-200 */
  --c-border-strong:#D1D5DB;  /* gray-300 */

  --c-text:        #0F172A;   /* slate-900 — primary, high contrast */
  --c-text-muted:  #475569;   /* slate-600 */
  --c-text-subtle: #94A3B8;   /* slate-400 */

  --c-accent:      #0F766E;   /* teal-700 — single, restrained accent */
  --c-accent-hover:#115E59;   /* teal-800 */
  --c-accent-soft: #CCFBF1;   /* teal-100 */

  --c-success:     #15803D;   /* green-700 */
  --c-success-soft:#DCFCE7;
  --c-warning:     #B45309;   /* amber-700 */
  --c-warning-soft:#FEF3C7;
  --c-danger:      #B91C1C;   /* red-700 */
  --c-danger-soft: #FEE2E2;
  --c-info:        #1D4ED8;   /* blue-700 */
  --c-info-soft:   #DBEAFE;

  /* --- Typography --------------------------------------------------------- */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --fs-xs:   12px;
  --fs-sm:   13px;
  --fs-base: 14px;
  --fs-md:   15px;
  --fs-lg:   18px;
  --fs-xl:   22px;
  --fs-2xl:  28px;

  --lh-tight: 1.25;
  --lh-base:  1.5;

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* --- Base reset ----------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg-subtle);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }

/* Inter via Google Fonts is pulled in from index.html. The fallback stack
   above guarantees system-default sans-serif if Inter fails to load. */

/* --- Layout primitives ---------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}

.sidebar { grid-area: sidebar; }
.topbar  { grid-area: topbar; }
.main    { grid-area: main; overflow-y: auto; }

/* Sidebar */
.sidebar {
  background: var(--c-text);           /* deep slate for high contrast */
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #000;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 56px;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: var(--fw-semi);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}
.sidebar__brand-mark {
  width: 24px; height: 24px;
  background: var(--c-accent);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-xs);
  color: #fff;
}
.sidebar__nav { padding: var(--sp-3); flex: 1; overflow-y: auto; }
.sidebar__section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748B;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: #CBD5E1;
  text-decoration: none;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  margin-bottom: 2px;
  transition: background 120ms ease, color 120ms ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.is-active {
  background: rgba(15, 118, 110, 0.22);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--c-accent);
}
.nav-link svg { width: 16px; height: 16px; opacity: 0.85; flex-shrink: 0; }

.sidebar__footer {
  padding: var(--sp-3);
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: var(--fs-xs);
  color: #64748B;
}

/* Topbar */
.topbar {
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
}
.topbar__title h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}
.topbar__title p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}
.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--c-bg-subtle); }
.btn--primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}
.btn--primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--c-bg-subtle); }
.btn--sm { height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

/* --- Cards / panels ------------------------------------------------------- */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
}
.panel__title { font-size: var(--fs-md); font-weight: var(--fw-semi); margin: 0; }
.panel__body { padding: var(--sp-5); }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
table.data thead th {
  text-align: left;
  font-weight: var(--fw-semi);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-muted);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-subtle);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
table.data thead th .sort-ind { opacity: 0.4; margin-left: 4px; font-size: 10px; }
table.data thead th.is-sorted .sort-ind { opacity: 1; color: var(--c-accent); }
table.data tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--c-bg-subtle); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-num { font-variant-numeric: tabular-nums; text-align: right; }
.cell-mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* --- Badges / pills ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 var(--sp-2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--c-bg-subtle);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
}
.badge--UGC        { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.badge--Lovelight  { background: #FCE7F3; color: #9D174D; border-color: #FBCFE8; }
.badge--VO         { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.badge--Standard   { background: #E0E7FF; color: #3730A3; border-color: #C7D2FE; }
.badge--Undefined  { background: var(--c-bg-subtle); color: var(--c-text-subtle); }
.badge--music      { background: var(--c-warning-soft); color: var(--c-warning); border-color: #FCD34D; }
.badge--standard   { background: var(--c-info-soft); color: var(--c-info); border-color: #93C5FD; }

/* --- KPI tiles (single-row stat strip, not a 3-card hero) ---------------- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}
.stat {
  border-left: 2px solid var(--c-accent);
  padding: var(--sp-2) var(--sp-4);
  background: transparent;
}
.stat__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-1);
}
.stat__value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.stat__delta { font-size: var(--fs-xs); color: var(--c-text-muted); margin: 2px 0 0; }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.field label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-text-muted); }
.input, .select {
  height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-bg);
  font-size: var(--fs-base);
  font-family: inherit;
  color: var(--c-text);
}
.input:focus, .select:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }

/* --- Alerts --------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid;
  font-size: var(--fs-sm);
}
.alert--error   { background: var(--c-danger-soft);  border-color: #FCA5A5; color: #7F1D1D; }
.alert--warning { background: var(--c-warning-soft); border-color: #FCD34D; color: #78350F; }
.alert--info    { background: var(--c-info-soft);    border-color: #93C5FD; color: #1E3A8A; }
.alert--success { background: var(--c-success-soft); border-color: #86EFAC; color: #14532D; }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* --- Skeleton loaders ----------------------------------------------------- */
.skel {
  background: linear-gradient(90deg, #EEF2F7 25%, #F8FAFC 37%, #EEF2F7 63%);
  background-size: 400% 100%;
  animation: skel 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 12px;
}
@keyframes skel {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skel--line { height: 12px; margin-bottom: 8px; }
.skel--cell { height: 16px; }
.skel--tile { height: 48px; width: 60%; }

/* --- Empty state ---------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;       /* left-aligned per design rules */
  text-align: left;
  gap: var(--sp-3);
  padding: var(--sp-9) var(--sp-6);
  max-width: 480px;
}
.empty__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--c-accent-soft);
  color: var(--c-accent);
  display: grid; place-items: center;
}
.empty__icon svg { width: 22px; height: 22px; }
.empty h2 { margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-semi); }
.empty p { margin: 0; color: var(--c-text-muted); max-width: 420px; }

/* --- Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center;
  z-index: 50;
}
.modal {
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: min(560px, calc(100vw - 48px));
  max-height: 85vh;
  overflow-y: auto;
}
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
}
.modal__body { padding: var(--sp-5); }
.modal__footer {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border);
}

/* --- Toast ---------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: 100;
}
.toast {
  background: var(--c-text);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in 180ms ease;
  max-width: 360px;
}
.toast--error { background: var(--c-danger); }
.toast--success { background: var(--c-success); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* --- Utility -------------------------------------------------------------- */
.muted { color: var(--c-text-muted); }
.subtle { color: var(--c-text-subtle); }
.tabular { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.row--between { justify-content: space-between; }
.row--gap { gap: var(--sp-2); }
.stack { display: flex; flex-direction: column; }
.grow { flex: 1; }
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Section spacing */
.section { padding: var(--sp-5) var(--sp-6); }
.section + .section { padding-top: 0; }

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

/* --- Date range picker ---------------------------------------------------- */
.date-range-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.date-range-picker__custom {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.date-range-picker__custom .input {
  width: 140px;
  font-size: var(--fs-sm);
}

/* Progress bar (sync) */
.progress {
  height: 4px;
  background: var(--c-bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--c-accent);
  width: 0%;
  transition: width 200ms ease;
}

/* Responsive: collapse sidebar below lg */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
