/* Alpha Drive AI brand surface for the Resolver Tester.
 *
 * Palette and type follow brand.alphadriveai.com/brand-guidelines.md:
 * Ink Black grounds every surface, Alpha Red is the only accent (never tinted
 * or gradiented), Deep Red carries depth, Smoke carries text. Neutrals between
 * Ink Black and Smoke are the only additions, used for elevation alone.
 * Metadata is monospace, uppercase, tracked; the wordmark is heavy italic with
 * the brand's -14 degree skew above its horizontal slice.
 */

:root {
  --alpha-red: #E30613;
  --deep-red: #AA0310;
  --ink: #0A0A0C;
  --smoke: #F2F2F0;

  --surface-1: #101013;
  --surface-2: #16161A;
  --surface-3: #1D1D22;
  --line: #26262C;
  --line-strong: #34343C;

  --text: var(--smoke);
  --text-dim: #A0A0A6;
  --text-faint: #6E6E76;

  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Courier New", Courier, ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 4px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* --- brand lockup ------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.wordmark {
  font-family: "Arial Black", "Arial Bold", Arial, var(--ui);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  font-size: 18px;
  line-height: 1;
  transform: skewX(-14deg);
  transform-origin: left bottom;
  padding-right: 6px;
  white-space: nowrap;
}

/* The horizontal slice of the mark, in the one accent colour. */
.slice {
  width: 34px;
  height: 3px;
  background: var(--alpha-red);
  align-self: center;
  flex: none;
}

.product {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hint {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

/* --- controls ----------------------------------------------------------- */

.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}

button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--alpha-red);
  outline-offset: 2px;
}

.primary {
  background: var(--alpha-red);
  color: var(--smoke);
}

.primary:hover:not(:disabled) { background: var(--deep-red); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }

.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-dim);
  font-weight: 600;
}

.ghost:hover { color: var(--text); border-color: var(--text-faint); }

.tiny {
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.block { width: 100%; }

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--text);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, select:focus, textarea:focus {
  border-color: var(--line-strong);
}

textarea { resize: vertical; }

/* --- layout ------------------------------------------------------------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface-1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.conv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conv-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  font-weight: 500;
}

.conv-item:hover { border-color: var(--line-strong); }

.conv-item[aria-current="true"] {
  border-color: var(--alpha-red);
  background: var(--surface-2);
}

.conv-item .conv-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item .conv-meta {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
}

.conv-item .conv-meta .done { color: var(--alpha-red); }

.empty, .note, .field-note {
  color: var(--text-faint);
  font-size: 12px;
  margin: 0;
}

/* --- conversation pane -------------------------------------------------- */

.pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pane-empty {
  margin: auto;
  max-width: 460px;
  padding: 40px 24px;
  text-align: center;
  display: grid;
  gap: 16px;
  justify-items: center;
}

.pane-empty p { color: var(--text-dim); margin: 0; }

.pane-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.pane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap);
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
  flex-wrap: wrap;
}

.pane-title h1 { font-size: 20px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px 8px;
  background: var(--surface-2);
}

.chip.accent { color: var(--smoke); border-color: var(--alpha-red); }
.chip.value { text-transform: none; letter-spacing: 0.04em; }

/* The vehicle sits beside the API key in the pane header. It is a property of
   the CONVERSATION, not of one turn - the API accumulates it across turns - so
   it belongs here rather than in the per-turn composer where it used to live. */
.pane-header-actions {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  flex-wrap: wrap;
}

.vehicle-field { display: grid; gap: 6px; min-width: 320px; }
.vehicle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 92px auto;
  gap: 6px;
  align-items: center;
}
.vehicle-grid input,
.vehicle-grid select {
  font-family: var(--mono);
  font-size: 12px;
  min-width: 0;
}
.hint-inline {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  margin-left: 6px;
}
.hint-inline code { font-size: 10px; }

.key-field { display: grid; gap: 6px; min-width: 280px; }
.key-input { display: flex; gap: 6px; align-items: center; }
.key-input input { font-family: var(--mono); font-size: 12px; }

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.turn { display: grid; gap: 8px; max-width: 780px; }
.turn.caller { justify-self: end; text-align: right; }

.bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn.caller .bubble {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.turn.resolved .bubble { border-color: var(--alpha-red); }
.turn.failed .bubble { border-color: var(--deep-red); }

.turn-meta {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.turn.caller .turn-meta { justify-content: flex-end; }

.opcodes { display: grid; gap: 6px; margin-top: 10px; }

.opcode {
  display: flex;
  gap: 10px;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.opcode:first-child { border-top: 0; padding-top: 0; }
.opcode code {
  font-family: var(--mono);
  color: var(--alpha-red);
  font-size: 12px;
  white-space: nowrap;
}

.raw summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.raw summary:hover { color: var(--text-dim); }

.raw pre {
  margin: 8px 0 0;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.system-note {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  border-left: 2px solid var(--alpha-red);
  padding-left: 10px;
}

/* --- composer ----------------------------------------------------------- */

.composer {
  border-top: 1px solid var(--line);
  background: var(--surface-1);
  padding: 14px 20px 18px;
  display: grid;
  gap: 12px;
}

.composer-main { display: flex; gap: 12px; align-items: flex-end; }
.composer-main textarea { flex: 1; }
.composer-main button { flex: none; }

.composer-extra summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.composer-extra summary:hover { color: var(--text-dim); }
.composer-extra[open] { display: grid; gap: 12px; }

.extra-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.extra-grid label, .seed-field { display: grid; gap: 6px; }
.seed-field textarea { font-family: var(--mono); font-size: 12px; }

/* --- dialog ------------------------------------------------------------- */

.dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
}

.dialog::backdrop { background: rgba(10, 10, 12, 0.78); }

.dialog form { padding: 22px; display: grid; gap: 16px; }
.dialog h2 { font-size: 18px; }
.dialog label { display: grid; gap: 6px; }

.dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
}

.dialog-error {
  margin: 0;
  color: var(--alpha-red);
  font-size: 13px;
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
  }
  .extra-grid { grid-template-columns: 1fr; }
  .composer-main { flex-direction: column; align-items: stretch; }
}
