/* Cockpit — minimal first-pass styling. Mobile-first, dark by default. */

:root {
  --bg: #0b0f14;
  --bg-elev: #131922;
  --bg-elev-2: #1b2230;
  --fg: #e6ecf3;
  --fg-dim: #98a4b3;
  --accent: #5ec2ff;
  --border: #232c3b;
  --good: #7ee787;
  --warn: #f0b86e;
  --bad:  #ff7b72;
  --ask:  #c084fc;
  --radius: 10px;
  --pad: 14px;
  --max: 880px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.5px; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--fg-dim); padding: 6px 8px; border-radius: var(--radius); }
.nav a.active { color: var(--fg); background: var(--bg-elev-2); }

.view { max-width: var(--max); margin: 0 auto; padding: 16px; }
.view h1 { font-size: 1.4rem; margin: 0 0 12px; }
.view h2 { font-size: 1.05rem; margin: 18px 0 8px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.loading { color: var(--fg-dim); padding: 24px 0; }
.empty { color: var(--fg-dim); padding: 24px 0; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 10px;
}
.card .row {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.card .summary { font-weight: 600; }
.card .reasoning { color: var(--fg-dim); font-size: 0.92rem; margin-top: 6px; }
.card .snippet {
  margin-top: 8px; padding: 8px 10px; background: var(--bg-elev-2);
  border-left: 3px solid var(--border); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
  white-space: pre-wrap;
}

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-elev-2); color: var(--fg-dim); border: 1px solid var(--border);
}
.tag.auto  { color: var(--good); border-color: rgba(126,231,135,0.35); }
.tag.draft { color: var(--warn); border-color: rgba(240,184,110,0.35); }
.tag.ask   { color: var(--ask);  border-color: rgba(192,132,252,0.35); }

.actions {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.btn {
  display: inline-block; padding: 8px 12px; border-radius: var(--radius);
  background: var(--bg-elev-2); color: var(--fg); border: 1px solid var(--border);
  cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--accent); color: #002033; border-color: var(--accent); }
.btn.danger { color: var(--bad); }

form.health-form { display: grid; gap: 10px; max-width: 520px; }
form.health-form label { display: grid; gap: 4px; color: var(--fg-dim); font-size: 0.9rem; }
form.health-form input, form.health-form textarea, form.health-form select {
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font: inherit;
}

/* ----- Queue cards (refined rendering) ----- */
.qcard {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; margin-bottom: 14px;
}
.qcard-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.qcard-title {
  font-size: 1rem; font-weight: 600; line-height: 1.35; margin: 0;
  color: var(--fg);
}
.qcard-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-elev-2); color: var(--fg-dim); border: 1px solid var(--border);
}
.qcard-reasoning {
  margin: 0; color: var(--fg-dim);
  font-size: 0.92rem; line-height: 1.55;
}
.qcard-detail {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; background: var(--bg);
}
.qcard-detail > summary {
  cursor: pointer; padding: 2px 0;
  color: var(--fg-dim);
  font-size: 0.74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  list-style: none;
}
.qcard-detail > summary::marker { content: ""; }
.qcard-detail > summary::-webkit-details-marker { display: none; }
.qcard-detail > summary::before {
  content: "▸"; display: inline-block; width: 1.2em; color: var(--fg-dim);
  transition: transform 0.15s;
}
.qcard-detail[open] > summary::before { transform: rotate(90deg); }
.qcard-quote {
  margin: 8px 0 4px; padding: 0 0 0 12px;
  border-left: 3px solid var(--border);
  color: var(--fg); font-size: 0.9rem; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
  font-family: inherit;
}

/* draft sub-renderings */
.draft-fields {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.draft-field {
  display: flex; gap: 12px; font-size: 0.88rem; align-items: baseline;
}
.draft-field .lbl {
  flex: 0 0 72px; color: var(--fg-dim);
  text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em;
  padding-top: 1px;
}
.draft-field .val {
  flex: 1; min-width: 0; word-break: break-word; color: var(--fg);
}
.draft-body {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg-elev); border-radius: 6px;
  white-space: pre-wrap; line-height: 1.5;
  font-size: 0.92rem; color: var(--fg);
}
.draft-items {
  display: flex; flex-direction: column; gap: 10px; margin-top: 8px;
}
.draft-item {
  padding: 10px 12px;
  background: var(--bg-elev); border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.draft-item-type {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--bg-elev-2); color: var(--accent); border: 1px solid var(--border);
}
.draft-item-desc {
  margin: 8px 0; font-size: 0.92rem; line-height: 1.5; color: var(--fg);
}
.draft-caution {
  margin-top: 8px; padding: 6px 10px;
  background: rgba(240,184,110,0.08); color: var(--warn);
  border-left: 3px solid var(--warn); border-radius: 4px;
  font-size: 0.85rem; line-height: 1.45;
}
.draft-caution::before { content: "⚠ "; font-weight: 700; }
.draft-note {
  margin-top: 4px; padding: 8px 12px;
  background: var(--bg-elev-2); border-radius: 6px;
  font-size: 0.88rem; color: var(--fg-dim);
  border-left: 3px solid var(--border);
}
.draft-note::before { content: "Note: "; color: var(--accent); font-weight: 600; }
.draft-json {
  margin: 8px 0 0; padding: 8px 10px;
  background: var(--bg-elev); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; line-height: 1.4; white-space: pre-wrap;
  color: var(--fg); max-height: 320px; overflow-y: auto;
}

/* ----- Queue filters ----- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 14px;
}
.filters input[type="search"], .filters select {
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; font: inherit;
}
.filters input[type="search"] { flex: 1 1 200px; min-width: 0; }
.filters select { flex: 0 0 auto; }
.filter-check {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fg-dim); font-size: 0.88rem; cursor: pointer;
}

/* ----- Chat bubble ----- */
.chat-toggle {
  position: fixed; right: 16px; bottom: 16px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #002033;
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.chat-toggle:hover { transform: scale(1.05); }

.chat-panel {
  position: fixed; right: 16px; bottom: 80px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  z-index: 51;
  overflow: hidden;
}
.chat-panel.hidden { display: none; }
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--bg-elev-2); border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.chat-close {
  background: transparent; border: none; color: var(--fg-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.chat-close:hover { color: var(--fg); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-msg {
  padding: 8px 12px; border-radius: 10px; max-width: 86%;
  white-space: pre-wrap; word-wrap: break-word;
  font-size: 0.92rem; line-height: 1.4;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--accent); color: #002033;
}
.chat-msg-assistant {
  align-self: flex-start;
  background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--border);
}
.chat-msg-system {
  align-self: stretch;
  background: transparent; color: var(--fg-dim);
  font-size: 0.85rem; padding: 4px 0;
  border: none;
}
.chat-msg-system em { color: var(--accent); font-style: normal; }
.chat-msg-loading { color: var(--fg-dim); font-style: italic; }
.chat-form {
  display: flex; gap: 8px; padding: 10px;
  border-top: 1px solid var(--border);
}
.chat-form textarea {
  flex: 1; resize: none;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font: inherit;
}
