/* ----------------------------------------------------------
   NelsonAI - Design System
   Tokens then components then utilities.
   Consumed alongside Tailwind CDN; the bg, border, and text
   color names in base.html's tailwind.config resolve to these
   CSS variables so both worlds stay in lock-step.
   ---------------------------------------------------------- */

:root {
  /* Surface */
  --bg:          #0a0a0b;
  --bg-raised:   #111113;
  --bg-card:     #141417;
  --bg-inset:    #1a1a1e;
  --bg-hover:    #1f1f24;

  /* Border */
  --border:        #26262c;
  --border-subtle: #1c1c21;
  --border-strong: #33333a;

  /* Foreground */
  --fg:         #f5f5f7;
  --fg-muted:   #a1a1aa;
  --fg-subtle:  #6b6b75;
  --fg-faint:   #4a4a52;

  /* Accent + semantic */
  --accent:        #3ecf8e;
  --accent-press:  #2da374;
  --accent-soft:   rgba(62, 207, 142, .10);
  --accent-ring:   rgba(62, 207, 142, .35);

  --danger:      #f87171;
  --danger-soft: rgba(248, 113, 113, .10);
  --warn:        #fbbf24;
  --warn-soft:   rgba(251, 191, 36, .10);
  --success:     #34d399;
  --success-soft:rgba(52, 211, 153, .10);
  --info:        #60a5fa;
  --info-soft:   rgba(96, 165, 250, .10);
  --purple:      #c084fc;
  --purple-soft: rgba(192, 132, 252, .10);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 120ms;
  --dur: 180ms;

  /* Elevation */
  --shadow-raised:  0 4px 12px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.04);
  --shadow-overlay: 0 24px 48px rgba(0,0,0,.6),  0 0 0 1px rgba(255,255,255,.06);
}

/* Global base */
html, body { background: var(--bg); color: var(--fg); }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Variable numerals everywhere that shows counts */
.tabular, th, td, .stat, [class*="tabular-nums"] {
  font-variant-numeric: tabular-nums;
}

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* ── Scrollbars ────────────────────────────────────────── */
::-webkit-scrollbar        { width: 10px; height: 10px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #26262c; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #33333a; }
* { scrollbar-width: thin; scrollbar-color: #26262c transparent; }

/* ── Focus rings ───────────────────────────────────────── */
:where(button, a, input, select, textarea, [tabindex], [role="button"]):focus { outline: none; }
:where(button, a, input, select, textarea, [tabindex], [role="button"]):focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: inherit;
}

/* Decorative icons never receive pointer events or SR focus */
svg[aria-hidden="true"] { pointer-events: none; }

/* Disabled affordance */
button:disabled, button[aria-disabled="true"],
[role="button"][aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .45;
}

/* Reduced motion: strip non-essential transitions */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ──────────────────────────────────────────────────────────
   Components
   ────────────────────────────────────────────────────────── */

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-header h2,
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.005em;
}

/* Stat card */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card .label { font-size: 12px; color: var(--fg-muted); font-weight: 500; }
.stat-card .value {
  font-size: 26px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1;
  margin-top: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .sub { font-size: 11px; color: var(--fg-subtle); margin-top: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; gap: 4px; }
.btn-primary { background: var(--accent); color: #08110d; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-press); }
.btn-secondary { background: var(--bg-inset); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-inset); color: var(--fg); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(248,113,113,.2); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.18); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  background: transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-inset); color: var(--fg); }

/* Inputs */
.input,
select.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.3;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--fg-faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: var(--accent); background: var(--bg-card); }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.45; }

.input-error { border-color: var(--danger) !important; }

/* Search input (icon prefix) */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--fg-subtle);
  pointer-events: none;
}
.search-wrap .input { padding-left: 34px; }

/* Select  -  custom chevron (compatible with native select) */
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b75' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}
select option { background: var(--bg-card); color: var(--fg); }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--fg); border-color: var(--border-strong); }
.chip[aria-pressed="true"],
.chip.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(62,207,142,.25);
}

/* Tier & score badges */
.tier-badge, .score-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  letter-spacing: .01em;
}
.tier-hot, .score-pill.hot   { background: var(--danger-soft);  color: var(--danger);  box-shadow: inset 0 0 0 1px rgba(248,113,113,.2); }
.tier-warm, .score-pill.warm { background: var(--warn-soft);    color: var(--warn);    box-shadow: inset 0 0 0 1px rgba(251,191,36,.2); }
.tier-pass, .score-pill.pass { background: var(--bg-inset);     color: var(--fg-subtle); box-shadow: inset 0 0 0 1px var(--border); }

/* Pipeline stage pill */
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  background: var(--bg-inset);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.stage-pill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--fg-faint); }
.stage-new          .dot { background: #8a8a94; }
.stage-contacted    .dot { background: var(--info); }
.stage-phone_screen .dot { background: #818cf8; }
.stage-submitted    .dot { background: var(--purple); }
.stage-interview    .dot { background: var(--warn); }
.stage-placed       .dot { background: var(--success); }
.stage-rejected     .dot { background: var(--danger); }

/* Tables */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--fg);
  border-bottom: 1px solid var(--border-subtle);
}
.table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}
.table tbody tr:hover { background: rgba(62, 207, 142, .04); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Candidate row (list variant) */
.candidate-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  transition: background var(--dur-fast) var(--ease);
}
.candidate-row:hover { background: rgba(62, 207, 142, .04); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }

/* Candidate card (board variant) */
.cand-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  cursor: pointer;
}
.cand-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }

/* Detail drawer */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-overlay);
  z-index: 41;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(20,20,23,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-body { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 50;
}
.modal-panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  z-index: 51;
}
.modal-body { padding: 24px; }

/* Section header (drawer subsections) */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-subtle);
  margin-bottom: 8px;
}
.section-header svg { width: 14px; height: 14px; }

/* Key-value grid */
.kv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px 18px;
  font-size: 12px;
}
@media (min-width: 640px) {
  .kv-grid { grid-template-columns: 1fr 1fr; }
}
.kv-grid dt { color: var(--fg-subtle); font-weight: 500; }
.kv-grid dd { color: var(--fg); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-muted);
}
.empty-state svg {
  width: 28px; height: 28px;
  color: var(--fg-faint);
  margin: 0 auto 12px;
}
.empty-state h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 12px;
  color: var(--fg-muted);
  max-width: 320px;
  margin: 0 auto 16px;
}

/* Skeleton loaders */
.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 0%, var(--bg-hover) 50%, var(--bg-inset) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--bg-inset); }
}

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs (underline) */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  padding-bottom: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 16px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-raised);
  font-size: 13px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in .22s var(--ease);
}
.toast.is-error   { border-color: rgba(248,113,113,.3); }
.toast.is-success { border-color: rgba(52,211,153,.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 4px;
  font-size: 13px;
  color: var(--fg-muted);
}

/* Scroll-shadow helper on horizontal scrollers */
.scroll-shadow {
  background:
    linear-gradient(to right, var(--bg-card) 30%, rgba(20,20,23,0)) left center,
    linear-gradient(to right, rgba(20,20,23,0), var(--bg-card) 70%) right center,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.35), rgba(0,0,0,0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.35), rgba(0,0,0,0)) right center;
  background-repeat: no-repeat;
  background-size: 24px 100%, 24px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* FTS search snippet highlights */
mark {
  background-color: var(--accent-soft);
  color: var(--fg);
  border-radius: 3px;
  padding: 0 2px;
}

/* Keyboard hint (kbd) */
kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--fg-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: inset 0 -1px 0 var(--border-subtle);
  line-height: 1;
}

/* Pulsing dot (running state) */
.dot-pulse {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--info);
  box-shadow: 0 0 0 0 rgba(96,165,250,.5);
  animation: pulse 1.4s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(96,165,250,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(96,165,250,0); }
  100% { box-shadow: 0 0 0 0 rgba(96,165,250,0); }
}
