/* ──────────────────────────────────────────────────────────────────────
   auto-poster — design system (dark, premium)
   ────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* surfaces */
  --bg:        #0A0A0B;
  --bg-2:      #101013;
  --bg-3:      #16161B;
  --bg-hover:  #1B1B22;

  /* borders */
  --line:      #1F1F26;
  --line-2:    #2A2A33;
  --line-3:    #3A3A45;

  /* ink */
  --text:      #F4F4F5;
  --text-2:    #A1A1AA;
  --text-3:    #6B6B75;
  --text-4:    #45454D;

  /* brand */
  --accent:    #6366F1;
  --accent-2:  #818CF8;
  --accent-soft: rgba(99, 102, 241, 0.12);

  /* page brand colors */
  --neelakkuyil: #06B6D4;
  --spot-reels:  #EC4899;

  /* status */
  --ok:     #22C55E;
  --warn:   #F59E0B;
  --danger: #EF4444;
  --info:   #6366F1;

  /* radius */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  /* shadow */
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 0 0 1px var(--line);
  --shadow-elev: 0 4px 24px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.03) inset;

  /* sidebar width */
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-2); text-decoration: none; transition: color .14s ease; }
a:hover { color: var(--text); }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace; font-feature-settings: 'tnum'; }
.dim  { color: var(--text-3); }
.muted{ color: var(--text-2); }
hr    { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
pre, code { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ─── App shell ───────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.brand .mark {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  position: relative;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.brand .mark::after {
  content: ''; position: absolute; inset: 8px;
  background: var(--bg-2); border-radius: 4px;
  mask: radial-gradient(circle at center, transparent 30%, black 31%);
}
.brand .name {
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.brand .tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text-3);
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.nav-list {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1;
}
.nav-section {
  padding: 14px 10px 6px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-4);
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  color: var(--text-2);
  transition: all .14s ease;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft); color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .ico {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; opacity: 0.8;
}
.nav-item.active .ico { opacity: 1; }

.sidebar-foot {
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  font-size: 12px; color: var(--text-3);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-foot .row {
  display: flex; align-items: center; gap: 8px;
  justify-content: space-between;
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18);
  animation: pulse 2.5s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(34,197,94,0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0.06); }
}

/* ─── Main ────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
  padding: 16px 32px;
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
}
.topbar h1 {
  margin: 0; font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar .spacer { flex: 1; }
.topbar .selector select {
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-family: inherit; font-size: 13px;
  padding: 7px 30px 7px 12px;
  border-radius: var(--r-sm);
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23A1A1AA' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color .14s ease;
}
.topbar .selector select:hover { border-color: var(--line-3); }

.content { padding: 28px 32px 60px; max-width: 1500px; width: 100%; }

/* ─── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  transition: border-color .14s ease;
}
.card:hover { border-color: var(--line-2); }
.card-row { display: flex; gap: 16px; }

.section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3);
  margin: 28px 0 12px; padding: 0 2px;
}
.section-title:first-child { margin-top: 4px; }

/* ─── Grid + flex helpers ─────────────────────────────────────────── */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.row-flex   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-end   { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.stack-sm   { display: flex; flex-direction: column; gap: 10px; }
.stack-md   { display: flex; flex-direction: column; gap: 16px; }

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all .14s ease;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--line-3); color: var(--text); }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: white; font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.btn-danger {
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.35);
  color: #FCA5A5;
}
.btn-danger:hover {
  background: var(--danger); border-color: var(--danger); color: white;
}
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ─── Pills ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 100px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-2);
  line-height: 1.4;
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
}
.pill.accent { color: var(--accent-2); border-color: rgba(99,102,241,0.35); background: var(--accent-soft); }
.pill.accent .dot { background: var(--accent); }
.pill.ok      { color: #86EFAC; border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.10); }
.pill.ok .dot { background: var(--ok); }
.pill.warn    { color: #FCD34D; border-color: rgba(245,158,11,0.4);  background: rgba(245,158,11,0.10); }
.pill.warn .dot { background: var(--warn); }
.pill.danger  { color: #FCA5A5; border-color: rgba(239,68,68,0.4);   background: rgba(239,68,68,0.10); }
.pill.danger .dot { background: var(--danger); }

/* page-specific brand pills */
.pill[data-brand="neelakkuyil"] {
  color: #67E8F9; border-color: rgba(6,182,212,0.35); background: rgba(6,182,212,0.10);
}
.pill[data-brand="neelakkuyil"] .dot { background: var(--neelakkuyil); }
.pill[data-brand="spot_reels"] {
  color: #F9A8D4; border-color: rgba(236,72,153,0.35); background: rgba(236,72,153,0.10);
}
.pill[data-brand="spot_reels"] .dot { background: var(--spot-reels); }

/* ─── Form fields ─────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .lbl {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  width: 100%;
  transition: border-color .14s ease, background .14s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:hover, textarea:hover, select:hover { border-color: var(--line-3); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-2);
}
textarea { resize: vertical; min-height: 60px; font-family: inherit; }

.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
}
.toggle input { display: none; }
.toggle .switch {
  position: relative;
  width: 36px; height: 20px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 100px;
  transition: all .18s ease;
}
.toggle .switch::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: all .18s ease;
}
.toggle input:checked + .switch {
  background: var(--accent-soft); border-color: var(--accent);
}
.toggle input:checked + .switch::after {
  left: 18px; background: var(--accent);
}

/* ─── Tables ──────────────────────────────────────────────────────── */
.dt {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.dt thead th {
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 12px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.dt tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr { transition: background .14s ease; }
.dt tbody tr:hover { background: var(--bg-3); }

/* ─── KPI cards ───────────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute;
  inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-3), transparent);
}
.kpi .lbl {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.kpi .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px; font-weight: 600;
  color: var(--text);
  margin-top: 6px; letter-spacing: -0.02em;
}
.kpi .sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ─── Queue card thumbnail ────────────────────────────────────────── */
.thumb {
  flex: 0 0 110px;
  width: 110px; height: 140px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card-headline {
  font-size: 15px; font-weight: 600; color: var(--text);
  line-height: 1.35; letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Empty state ─────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  color: var(--text-2);
}
.empty .ico {
  font-size: 36px; margin-bottom: 12px; opacity: 0.5;
}

/* ─── Login ───────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(99,102,241,0.12), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(236,72,153,0.10), transparent 40%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-elev);
}
.login-hero {
  text-align: center;
  margin-bottom: 28px;
}
.login-hero .mark {
  width: 52px; height: 52px;
  border-radius: 12px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), #A78BFA);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white; font-weight: 700;
  box-shadow: 0 8px 28px rgba(99,102,241,0.40);
}
.login-hero h1 {
  margin: 0; font-size: 22px; font-weight: 700;
  letter-spacing: -0.015em;
}
.login-hero p {
  margin: 6px 0 0;
  font-size: 13px; color: var(--text-3);
}
.login-error {
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.35);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ─── Score badge for topics ──────────────────────────────────────── */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: var(--r-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 600;
}

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto;
    flex-direction: row; padding: 12px;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { padding: 0; border: 0; margin: 0 16px 0 4px; }
  .sidebar-foot { display: none; }
  .nav-list { flex-direction: row; flex: 1; }
  .nav-item { padding: 6px 10px; }
  .nav-item .ico { display: none; }
  .topbar  { padding: 14px 18px; }
  .content { padding: 18px; }
  .card-row { flex-direction: column; }
  .thumb { width: 100%; height: 180px; }
}

/* ─── Backend (renderer version) selector card ────────────────────── */
.backend-card {
  display: block;
  padding: 16px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  transition: all .14s ease;
  position: relative;
}
.backend-card:hover { border-color: var(--line-3); background: var(--bg-hover); }
.backend-card input[type="radio"] { display: none; }
.backend-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
