/* ── CSS Variables ───────────────────────────────────────────────────────── */
:root {
  --bg: #0d0d10;
  --bg-2: #141418;
  --bg-3: #1c1c23;
  --bg-4: #24242e;
  --border: #2a2a35;
  --border-strong: #3a3a48;
  --text: #e2e4ea;
  --text-dim: #9ca3af;
  --text-faint: #6b7280;
  --accent: #6366f1;
  --accent-hover: #4f52d4;
  --success: #22c55e;
  --success-bg: rgba(34,197,94,.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,.1);
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.2);
}
video { max-width: 100%; border-radius: var(--radius); display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sidebar-mark svg { color: var(--accent); flex-shrink: 0; }

.nav {
  flex: 1;
  padding: 8px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-dim);
  font-size: 13.5px;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link--active { color: var(--text); background: var(--bg-3); }
.nav-link--active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-link--disabled { opacity: .4; cursor: default; pointer-events: none; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--bg-4);
  color: var(--text-faint);
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-foot button {
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  transition: background .15s, color .15s;
}
.sidebar-foot button:hover { background: var(--bg-3); color: var(--text); }

.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg);
}

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.last-updated { font-size: 12px; color: var(--text-faint); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--secondary { background: var(--bg-3); color: var(--text); border-color: var(--border); }
.btn--secondary:hover:not(:disabled) { background: var(--bg-4); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover:not(:disabled) { background: #16a34a; }
.btn--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn--full { width: 100%; justify-content: center; }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--xs { padding: 3px 7px; font-size: 11.5px; }
.btn--disabled { opacity: .4; cursor: not-allowed; }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-header .panel-title { margin-bottom: 0; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mt-2 { margin-top: 8px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-input { display: block; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13.5px; }
.form-input--sm { font-size: 12.5px; padding: 5px 8px; }
.form-textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
.form-hint--warn { color: var(--warn); }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.checkbox-label input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ── Two-column layout ───────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Metrics Dashboard ───────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.metric-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.metric-platform-icon { font-size: 18px; }
.metric-platform-name { font-weight: 600; font-size: 14px; flex: 1; }
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.metric-item { background: var(--bg-3); border-radius: 4px; padding: 6px 8px; }
.metric-label { display: block; font-size: 10.5px; color: var(--text-faint); margin-bottom: 2px; }
.metric-value { font-size: 18px; font-weight: 600; color: var(--text-dim); }
.sparkline-area { height: 40px; background: var(--bg-3); border-radius: 4px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.sparkline-placeholder { font-size: 11px; color: var(--text-faint); }
.metric-card__footer { font-size: 11px; color: var(--text-faint); text-align: center; }

.coming-soon-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}
.coming-soon-panel__icon { font-size: 32px; margin-bottom: 12px; }
.coming-soon-panel__title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.coming-soon-panel__body { font-size: 13.5px; color: var(--text-dim); max-width: 520px; margin: 0 auto 16px; line-height: 1.6; }

.coming-soon-page { text-align: center; padding: 60px 40px; }
.coming-soon-page__icon { font-size: 48px; margin-bottom: 16px; }
.coming-soon-page h2 { font-size: 24px; margin-bottom: 8px; }
.coming-soon-page__subtitle { font-size: 15px; color: var(--text-dim); margin-bottom: 24px; }
.coming-soon-page__desc { font-size: 13.5px; color: var(--text-dim); max-width: 560px; margin: 0 auto 24px; line-height: 1.7; }
.coming-soon-page__desc p + p { margin-top: 10px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.badge--coming-soon { background: var(--bg-4); color: var(--text-faint); border-color: var(--border); }
.badge--large { font-size: 13px; padding: 5px 14px; }
.badge--type { background: rgba(99,102,241,.12); color: var(--accent); border-color: rgba(99,102,241,.3); }
.badge--status { background: var(--bg-3); color: var(--text-dim); border-color: var(--border); }
.badge--approved { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.badge--pending { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.badge--primary-img { background: var(--success-bg); color: var(--success); border-color: transparent; font-size: 10px; }

/* ── Steps ───────────────────────────────────────────────────────────────── */
.steps-container { margin-bottom: 20px; }
.steps { display: flex; align-items: center; gap: 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); min-width: 80px; }
.step--active { color: var(--accent); }
.step--done { color: var(--success); }
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.step--active .step-dot { border-color: var(--accent); background: rgba(99,102,241,.15); color: var(--accent); }
.step--done .step-dot { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 20px; }

/* ── Script Cards ────────────────────────────────────────────────────────── */
.scripts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.script-card { background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.script-card__variant { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.script-card__hook, .script-card__body, .script-card__cta { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.5; }
.script-card__meta { font-size: 11.5px; color: var(--text-faint); }
.script-meta { font-size: 12.5px; color: var(--text-faint); margin-top: -6px; margin-bottom: 14px; }

/* ── Job Status ──────────────────────────────────────────────────────────── */
.job-status-box { background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.job-status-label { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.text-success { color: var(--success); }
.text-error { color: var(--danger); }
.text-pending { color: var(--text-dim); }

.job-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.job-row:last-child { border-bottom: none; }
.job-row__id { font-family: monospace; font-size: 11.5px; color: var(--text-faint); }
.job-row__product { flex: 1; color: var(--text-dim); }
.job-row__date { font-size: 12px; color: var(--text-faint); }

.job-status-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.job-status-badge--completed { background: var(--success-bg); color: var(--success); }
.job-status-badge--failed { background: var(--danger-bg); color: var(--danger); }
.job-status-badge--pending, .job-status-badge--submitting { background: var(--bg-4); color: var(--text-faint); }
.job-status-badge--generating, .job-status-badge--running { background: rgba(99,102,241,.1); color: var(--accent); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Products Grid ───────────────────────────────────────────────────────── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.product-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.product-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.product-card__img { width: 100%; height: 160px; object-fit: cover; display: block; }
.product-card__img--placeholder { height: 160px; background: var(--bg-3); display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 12px; }
.product-card__body { padding: 12px; }
.product-card__name { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.product-card__brand { font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.product-card__image-count { font-size: 11px; color: var(--text-faint); }

/* UGC small product grid */
.product-grid-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.product-card-sm { background: var(--bg-3); border: 2px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s; }
.product-card-sm:hover { border-color: var(--border-strong); }
.product-card--selected { border-color: var(--accent) !important; }
.product-card-img { width: 100%; height: 100px; object-fit: cover; display: block; }
.product-card-img--placeholder { height: 100px; background: var(--bg-4); display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 11px; }
.product-card-sm__name { padding: 7px 8px; font-size: 12px; font-weight: 500; text-align: center; }

/* ── Image Gallery ───────────────────────────────────────────────────────── */
.img-gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.img-gallery-item { position: relative; }
.img-gallery-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius-sm); display: block; border: 1px solid var(--border); }
.img-gallery-actions { position: absolute; inset: 0; background: rgba(0,0,0,.6); border-radius: var(--radius-sm); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.img-gallery-item:hover .img-gallery-actions { display: flex; }

.image-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.image-preview-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ── Drop Zone ───────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.drop-zone--active { border-color: var(--accent); background: rgba(99,102,241,.06); }
.drop-zone .link { cursor: pointer; }

/* ── Posts ───────────────────────────────────────────────────────────────── */
.posts-list { display: flex; flex-direction: column; gap: 8px; }
.post-item { background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.post-item__text { font-size: 13.5px; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.post-item__meta { font-size: 11.5px; color: var(--text-faint); }

/* ── Library ─────────────────────────────────────────────────────────────── */
.library-filters { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.lib-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.lib-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.lib-card__thumb { width: 100%; height: 130px; object-fit: cover; display: block; }
.lib-card__thumb--placeholder { height: 130px; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.lib-card__info { padding: 10px; }
.lib-card__title { font-size: 12.5px; font-weight: 500; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card__badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.lib-card__date { font-size: 11px; color: var(--text-faint); }

/* ── Video preview ───────────────────────────────────────────────────────── */
.video-preview { max-height: 400px; border-radius: var(--radius); background: #000; }
.video-preview--modal { max-height: 60vh; width: 100%; }

/* ── Notices ─────────────────────────────────────────────────────────────── */
.notice-banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.notice-banner--warn { background: var(--warn-bg); border-color: rgba(245,158,11,.3); color: var(--warn); }
.notice-banner--warn small { color: var(--text-dim); }
.notice-banner--warn code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

.success-banner { background: var(--success-bg); border: 1px solid rgba(34,197,94,.3); color: var(--success); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; display: flex; align-items: center; gap: 10px; }
.success-banner .link { color: var(--success); font-weight: 500; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { color: var(--text-faint); font-size: 13.5px; text-align: center; padding: 32px 16px; }

/* ── Text helpers ────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-dim); font-size: 13.5px; }
.text-error { color: var(--danger); font-size: 13.5px; }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  color: var(--text-faint);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: var(--bg-3); }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 18px; padding-right: 30px; }
.modal-media { margin-bottom: 16px; }
.modal-info h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toast-host {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  max-width: 320px;
  border: 1px solid transparent;
}
.toast--info { background: var(--bg-4); color: var(--text); border-color: var(--border-strong); }
.toast--success { background: var(--success-bg); color: var(--success); border-color: rgba(34,197,94,.3); }
.toast--error { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,.3); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 20px; margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
