/* =========================================================
   Cockpit — calm, friendly apply screen (detail page only)
   Loaded AFTER style.css. Everything is scoped to body.cockpit
   so the dashboard/pipeline pages are untouched.

   Theme is a token layer: soft-light is the default, warm-dark
   is opt-in via body.cockpit[data-theme="dark"]. The existing
   components (.btn-primary, .state-pill, .submission-banner,
   inputs…) read these same --vars, so they re-skin for free.
   ========================================================= */

/* ---- Soft-light tokens (default) ---- */
body.cockpit {
  --bg: #FAF9F6;              /* warm paper */
  --surface: #FFFFFF;        /* warm-white card */
  --surface-2: #F4F2EC;      /* layered surface */
  --border: #E7E3DA;
  --border-strong: #D8D3C7;
  --text: #1B1A17;           /* near-black ink */
  --text-dim: #6B6760;
  --text-faint: #746f66;      /* AA-readable small secondary text on paper */

  --accent: #4ec880;         /* signal green = GO/action (unchanged) */
  --accent-strong: #3fb46f;
  --accent-dim: rgba(78, 200, 128, 0.14);
  --green: #257e4d;          /* AA-readable green text on paper */
  --green-dim: rgba(78, 200, 128, 0.14);
  --amber: #C8881F;
  --amber-dim: rgba(200, 136, 31, 0.12);
  --red: #C8504B;
  --red-dim: rgba(217, 100, 95, 0.10);

  --btn-ink: #0f2b1c;        /* dark text on the green primary */

  --r-card: 14px;
  --r-btn: 10px;
  --radius: 12px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(40,33,20,0.04), 0 1px 3px rgba(40,33,20,0.06);
  --shadow-md: 0 2px 8px rgba(40,33,20,0.06), 0 10px 28px rgba(40,33,20,0.06);

  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  border-top-color: var(--accent);
}

/* ---- Warm-dark tokens (toggle) ---- */
body.cockpit[data-theme="dark"] {
  --bg: #15171a;             /* warm charcoal, not cold blue-black */
  --surface: #1c1f23;
  --surface-2: #23272c;
  --border: #2c3036;
  --border-strong: #3a3f47;
  --text: #ECEAE2;
  --text-dim: #9a9ca6;
  --text-faint: #8b8e96;

  --green: #5fd28f;
  --green-dim: rgba(78, 200, 128, 0.14);
  --amber: #e0a13c;
  --amber-dim: rgba(224, 161, 60, 0.12);
  --red: #ef6f6f;
  --red-dim: rgba(239, 111, 111, 0.12);

  --btn-ink: #0f1012;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3), 0 10px 28px rgba(0,0,0,0.35);
}

/* Use Inter for long-form reading; keep Space Grotesk for headings/labels. */
body.cockpit { font-family: var(--body); }
body.cockpit h1, body.cockpit h2, body.cockpit h3 { font-family: var(--display); }

/* Softer global radii + warmer surfaces for the reused components. */
body.cockpit .fill-bar,
body.cockpit .answer-block,
body.cockpit .submission-banner,
body.cockpit .submit-timeline,
body.cockpit .artifact-run,
body.cockpit .agent-summary { border-radius: var(--r-card); }

body.cockpit .fill-bar {
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
  padding: 18px;
}

body.cockpit .btn-primary,
body.cockpit .btn-secondary { border-radius: var(--r-btn); }
body.cockpit .btn-primary { color: var(--btn-ink); }

/* Calmer textareas: comfortable, not 50vh-tall. */
body.cockpit textarea { min-height: 200px; box-shadow: var(--shadow-sm); }
body.cockpit textarea[rows="3"] { min-height: 84px; }

/* =========================================================
   COCKPIT HEADER (neutral brand + theme toggle)
   ========================================================= */
.cockpit-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.cockpit-brand a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cockpit-brand a:hover { opacity: 0.82; }
.cockpit-brand .dot {
  width: 10px; height: 10px; border-radius: 999px; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem; line-height: 1;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* =========================================================
   HERO + STAT CHIPS
   ========================================================= */
.cockpit-hero { padding: 20px 0 10px; }
.cockpit-hero .greeting {
  font-family: var(--display); font-weight: 600;
  color: var(--text-dim); font-size: 0.9rem; margin-bottom: 4px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.78rem; font-weight: 600;
  font-family: var(--mono);
}
.chip .chip-key { color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.64rem; }
.chip.chip-accent { background: var(--accent-dim); color: var(--green); border-color: rgba(78,200,128,0.35); }

/* =========================================================
   STEPPER — the calm guide rail
   ========================================================= */
.stepper {
  list-style: none; margin: 18px 0 8px; padding: 0;
  display: flex; align-items: flex-start; gap: 0;
}
.stepper .step {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
/* connector line between steps */
.stepper .step::before {
  content: ""; position: absolute; top: 15px; left: -50%; width: 100%;
  height: 2px; background: var(--border-strong); z-index: 0;
}
.stepper .step:first-child::before { display: none; }
.stepper .step.is-done::before,
.stepper .step.is-active::before { background: var(--accent); }
.stepper .step-dot {
  position: relative; z-index: 1;
  width: 32px; height: 32px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid var(--border-strong);
  color: var(--text-faint); font-weight: 700; font-size: 0.82rem;
  font-family: var(--mono);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.stepper .step-label {
  font-size: 0.72rem; color: var(--text-faint); font-weight: 600;
  font-family: var(--display); line-height: 1.25; max-width: 11ch;
}
.stepper .step.is-active .step-dot {
  background: var(--accent); border-color: var(--accent); color: var(--btn-ink);
  box-shadow: 0 0 0 5px var(--accent-dim);
}
.stepper .step.is-active .step-label { color: var(--text); }
.stepper .step.is-done .step-dot {
  background: var(--accent-dim); border-color: var(--accent); color: var(--green);
}
.stepper .step.is-done .step-label { color: var(--text-dim); }

/* =========================================================
   COLLAPSIBLE PANEL (native <details>) — preview + expand
   ========================================================= */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  margin: 10px 0;
  overflow: hidden;
}
.panel > .panel__head {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  font-family: var(--display);
  transition: background 0.15s var(--ease);
}
.panel > .panel__head::-webkit-details-marker { display: none; }
.panel > .panel__head:hover { background: var(--surface-2); }
.panel__title { font-weight: 600; font-size: 0.92rem; color: var(--text); white-space: nowrap; }
.panel__preview {
  color: var(--text-faint); font-size: 0.82rem; font-family: var(--body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.panel[open] .panel__preview { display: none; }
.panel__chev {
  margin-left: auto; width: 18px; height: 18px; flex-shrink: 0;
  stroke: var(--text-faint); fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s var(--ease);
}
.panel[open] .panel__chev { transform: rotate(180deg); }
.panel__body { padding: 0 16px 16px; }
.panel__body > .section-title:first-child { margin-top: 4px; }
/* a green "needs you" accent variant for the active review step */
.panel.panel--active { border-color: rgba(78,200,128,0.4); box-shadow: 0 0 0 3px var(--accent-dim); }

/* =========================================================
   APPLY ZONE — one clear primary action
   ========================================================= */
.cockpit-apply { margin: 12px 0 18px; }
.btn-hero {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font-size: 1rem; padding: 15px 22px; min-height: 52px;
  box-shadow: var(--shadow-sm);
}
.btn-hero:hover { box-shadow: var(--shadow-md); }
.btn-ghost {
  font-family: var(--display); font-weight: 600; font-size: 0.88rem;
  padding: 10px 14px; border-radius: var(--r-btn); min-height: 40px;
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.btn-ghost:hover { color: var(--accent); background: var(--accent-dim); text-decoration: none; }
a.btn-ghost { display: inline-flex; align-items: center; justify-content: center; }

body.cockpit .apply-banner {
  border-radius: var(--radius-sm);
  border-left-width: 3px;
}

/* =========================================================
   EMBEDDED LIVE BROWSER (noVNC)
   ========================================================= */
.vnc-panel {
  margin: 14px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.vnc-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--text-dim); font-family: var(--mono);
  margin-bottom: 10px;
}
.vnc-status .led {
  width: 9px; height: 9px; border-radius: 999px; background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim); flex-shrink: 0;
}
.vnc-status.is-ready { color: var(--green); }
.vnc-status.is-ready .led { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.vnc-status.is-error { color: var(--red); }
.vnc-status.is-error .led { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.vnc-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border-strong); background: var(--surface-2);
}
.vnc-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.vnc-panel .btn-ghost { margin-top: 10px; }
.vnc-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 8px; line-height: 1.5; }

/* =========================================================
   SKELETON (loading shimmer)
   ========================================================= */
.skeleton { position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: cockpit-shimmer 1.4s infinite;
}
body.cockpit[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  background-size: 200% 100%;
}
@keyframes cockpit-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Standalone skeleton blocks (e.g. the generating-draft placeholder) need a base
   surface for the shimmer to read against; elements like .vnc-frame supply their own. */
.gen-skeleton { margin-top: 8px; }
.gen-skeleton .skeleton { background: var(--surface-2); border: 1px solid var(--border); }

/* Empty-state copy for the Activity view and other "nothing here yet" panels. */
.empty-state {
  color: var(--text-faint); font-size: 0.9rem; line-height: 1.6;
  padding: 22px 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.vnc-status-text { font-size: 0.82rem; color: var(--text-dim); }

/* =========================================================
   TOAST (themed; edit.js attaches these classes)
   ========================================================= */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  max-width: 90vw; padding: 11px 18px; border-radius: var(--r-btn);
  font-weight: 600; font-size: 0.88rem; z-index: 300;
  box-shadow: var(--shadow-md); opacity: 0;
  transition: opacity 0.25s var(--ease);
  color: #fff;
}
.toast.toast--ok { background: var(--accent-strong); color: var(--btn-ink); }
.toast.toast--error { background: var(--red); color: #fff; }
@media (min-width: 768px) { .toast { bottom: 24px; } }

/* =========================================================
   FOCUS RINGS (accessibility)
   ========================================================= */
body.cockpit :focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-dim);
  border-radius: 4px;
}

/* =========================================================
   MOTION SAFETY
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  body.cockpit *, body.cockpit *::before, body.cockpit *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================
   DASHBOARD + PIPELINE polish (shared components, soft-light)
   ========================================================= */
/* Bento stat cards instead of the dark hairline slab. */
body.cockpit .stats-bar {
  background: transparent; border: 0; gap: 12px; overflow: visible;
}
body.cockpit .stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm); padding: 16px 18px;
}
body.cockpit .stat-card .value { color: var(--text); }
body.cockpit .stat-card .value.green, body.cockpit .stat-card .value.accent { color: var(--green); }

/* Calm list cards. */
body.cockpit .app-card, body.cockpit .recent-card, body.cockpit .job-row {
  border-radius: var(--r-card); box-shadow: var(--shadow-sm);
  border-color: var(--border); border-left-color: var(--border);
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease), transform .06s var(--ease);
}
body.cockpit .app-card:hover, body.cockpit .recent-card:hover, body.cockpit .job-row:hover {
  box-shadow: var(--shadow-md); border-left-color: var(--accent);
}
body.cockpit .filter-bar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm);
}
body.cockpit .footer-note { color: var(--text-faint); }
body.cockpit .salary, body.cockpit .job-row .score { color: var(--green); }

/* Segmented control — the dashboard "manage" filter. */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px;
  padding: 4px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.seg-btn {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 0.8rem;
  color: var(--text-dim); padding: 7px 14px; border-radius: 999px; min-height: 34px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on { background: var(--accent); color: var(--btn-ink); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 560px) {
  .stepper .step-label { font-size: 0.66rem; max-width: 9ch; }
  .panel__title { white-space: normal; }
}
@media (min-width: 768px) {
  .btn-hero { width: auto; min-width: 280px; }
}

/* =========================================================
   Interview-stage breadcrumb (`.istage`) — shared component.
   Used on the Applications rows, the app detail header, and the
   Machine loop panel. Theme-aware through cockpit vars only, so it
   works in both light and warm-dark with no per-page overrides.
   Pipeline: recruiter -> assessment -> tech -> onsite -> offer.
   ========================================================= */
.istage {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.02em;
}
.istage-step {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--text-faint);
}
.istage-node {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--border-strong);
}
.istage-step.is-past { color: var(--text-dim); }
.istage-step.is-past .istage-node { background: var(--green); }
.istage-step.is-current {
  color: var(--text); font-weight: 700; background: var(--accent-dim);
}
.istage-step.is-current .istage-node {
  background: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-dim);
}
.istage-sep { color: var(--text-faint); opacity: 0.55; padding: 0 1px; }

/* Compact variant for dense table rows: collapse to dots plus the
   current step's label, drop the separators. */
.istage--compact { gap: 4px; }
.istage--compact .istage-step { padding: 1px 3px; }
.istage--compact .istage-sep { display: none; }
.istage--compact .istage-label { display: none; }
.istage--compact .istage-step.is-current { padding: 1px 8px; }
.istage--compact .istage-step.is-current .istage-label { display: inline; }

/* Next upcoming step line. */
.istage-next {
  margin: 7px 0 0; font-family: var(--body); font-size: 0.8rem;
  color: var(--text-dim); line-height: 1.45;
}
.istage-next-key {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-faint); margin-right: 7px;
}
.istage-next time, .istage-next b { color: var(--text); font-weight: 600; }
