/* SecQuest design system — modern, minimal, themeable.
 *
 * Hand-authored (no CDN) so the strict CSP `style-src 'self'` holds.
 * Light/dark are driven by `data-theme` on <html>; tokens below are the only
 * place colors live, so theming stays consistent everywhere. */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --ring: 0 0 0 3px var(--accent-ring);
  --shadow: 0 1px 2px rgba(2, 6, 23, .04), 0 8px 24px -12px rgba(2, 6, 23, .12);
  --shadow-lg: 0 12px 40px -12px rgba(2, 6, 23, .25);
  --transition: 160ms cubic-bezier(.4, 0, .2, 1);
}

/* ── Light theme (default) ── */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #eef2ff 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 0%, #ecfeff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e8ec;
  --border-strong: #d4d8df;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-fg: #ffffff;
  --accent-ring: rgba(79, 70, 229, .25);
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --warn: #d97706;
  --chip: #eef2ff;
  --chip-fg: #4338ca;
}

/* ── Dark theme ── */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b10;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(79, 70, 229, .14) 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 0%, rgba(6, 182, 212, .10) 0%, transparent 55%);
  --surface: #14161d;
  --surface-2: #1a1d27;
  --border: #262a36;
  --border-strong: #333847;
  --text: #e7e9ee;
  --text-muted: #9aa3b2;
  --text-faint: #6b7280;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-fg: #0a0b10;
  --accent-ring: rgba(129, 140, 248, .3);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .12);
  --danger: #f87171;
  --warn: #fbbf24;
  --chip: rgba(129, 140, 248, .14);
  --chip-fg: #c7d2fe;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition), color var(--transition);
}

/* ── Layout ── */
.container { max-width: 980px; margin: 0 auto; padding: 28px 20px 64px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* ── Header / brand ── */
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: grid; place-items: center; color: #fff; font-weight: 700;
  box-shadow: var(--shadow);
}
.brand-title { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: .78rem; color: var(--text-muted); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.card-title { font-weight: 600; font-size: .98rem; margin: 0 0 4px; }
.card-desc { color: var(--text-muted); font-size: .85rem; margin: 0 0 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Forms ── */
label.field { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; }
.input, select.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input::placeholder { color: var(--text-faint); }
.input:focus, select.input:focus { border-color: var(--accent); box-shadow: var(--ring); }

/* File input */
.file-input { font-size: .85rem; color: var(--text-muted); }
.file-input::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); border-radius: 999px;
  cursor: pointer; font: inherit; transition: var(--transition);
}
.file-input::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font: inherit; font-weight: 550; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.btn:focus-visible { box-shadow: var(--ring); outline: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-block { width: 100%; }

/* Icon-only button (theme toggle) */
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
/* show sun in dark mode, moon in light mode */
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ── Chips / badges ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip); color: var(--chip-fg);
  padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600;
}
.badge {
  font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  text-transform: capitalize; border: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface-2);
}
.badge-completed, .badge-ready { color: var(--success); background: var(--success-soft); border-color: transparent; }
.badge-processing, .badge-pending { color: var(--warn); border-color: transparent; }
.badge-failed { color: var(--danger); border-color: transparent; }

/* ── Result cards ── */
.answer { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; background: var(--surface-2); }
.answer + .answer { margin-top: 12px; }
.answer-q { font-weight: 600; margin: 0 0 6px; }
.answer-a { color: var(--text); margin: 0 0 10px; white-space: pre-wrap; }
.answer-meta { display: flex; align-items: center; gap: 10px; font-size: .75rem; color: var(--text-faint); }

/* Confidence meter */
.meter { flex: 1; max-width: 140px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #06b6d4); border-radius: 999px; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table thead th {
  text-align: left; font-weight: 600; font-size: .75rem; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.link { color: var(--accent); cursor: pointer; font-weight: 550; }
.link:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Auth screen ── */
.auth-card {
  width: 360px; max-width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 32px;
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }

/* ── Helpers ── */
/* Utility classes (replace inline style attrs so `style-src 'self'` CSP holds) */
.no-m { margin: 0; }
.mt-sm { margin-top: 10px; }
.mt-md { margin-top: 12px; }
.mt-xs { margin-top: 4px; }
.mb-md { margin-bottom: 14px; }
.w-auto { width: auto; }
.w-search { width: 260px; max-width: 100%; }
.center { justify-content: center; }
.section-head .card-title { margin: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: .82rem; }
.err { color: var(--danger); font-size: .85rem; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }

/* Toast / inline status */
.status { font-size: .82rem; color: var(--text-muted); min-height: 1.2em; }
.status.ok { color: var(--success); }
.status.bad { color: var(--danger); }

/* Spinner */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .container { padding: 18px 14px 48px; }
  .auth-card { padding: 24px; }
}
