/* ─────────────────────────────────────────────────────────────────────────
   Concept-to-Code Creation Station — stylesheet
   Dark theme, system fonts, CSS variables, no CDN.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Variables ── */
:root {
  --bg:           #0e0e12;
  --bg2:          #16161e;
  --bg3:          #1e1e2a;
  --border:       #2a2a3a;
  --text:         #d4d4e8;
  --text-dim:     #7070a0;
  --accent:       #7c6af7;
  --accent-hover: #9b8cff;
  --ok:           #3ecf8e;
  --warn:         #f5a623;
  --err:          #e05c5c;
  --run:          #4caf7d;
  --run-hover:    #5dcf93;
  --cancel:       #c0392b;
  --cancel-hover: #e74c3c;
  --hf-orange:    #ff6b35;
  --venice-blue:  #4a9eff;
  --radius:       6px;
  --font-mono:    "JetBrains Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
  --font-ui:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar-h:     48px;
  --backend-h:    44px;
  --footer-h:     32px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--accent); letter-spacing: 0.02em; }
.brand-sub  { font-size: 12px; color: var(--text-dim); }

.status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  margin-left: auto;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.25s;
}
.status[data-state="idle"]    .status-dot { background: var(--text-dim); }
.status[data-state="running"] .status-dot { background: var(--warn); animation: pulse 1s infinite; }
.status[data-state="ok"]      .status-dot { background: var(--ok); }
.status[data-state="error"]   .status-dot { background: var(--err); }
.status[data-state="idle"]    #statusText { color: var(--text-dim); }
.status[data-state="running"] #statusText { color: var(--warn); }
.status[data-state="ok"]      #statusText { color: var(--ok); }
.status[data-state="error"]   #statusText { color: var(--err); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: 16px; }
.version { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

/* ── Backend selector bar ── */
.backend-bar {
  height: var(--backend-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.backend-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
}
.backend-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.backend-select,
.model-select {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.backend-select:focus,
.model-select:focus { border-color: var(--accent); }
.backend-select:disabled,
.model-select:disabled { opacity: 0.5; cursor: not-allowed; }
.backend-select option[value="openai"]      { color: var(--ok); }
.backend-select option[value="huggingface"] { color: var(--hf-orange); }
.backend-select option[value="venice"]      { color: var(--venice-blue); }
.backend-select option[value="fake"]        { color: var(--text-dim); }
.btn-apply {
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  font-size: 12px;
}
.btn-apply:not(:disabled):hover { background: var(--accent-hover); }
.backend-status {
  font-size: 11px;
  color: var(--ok);
  font-family: var(--font-mono);
  min-width: 80px;
}
.backend-status.err { color: var(--err); }
.key-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.key-inputs.hidden { display: none; }
.api-key-input {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  width: 220px;
  outline: none;
}
.api-key-input:focus { border-color: var(--accent); }
.btn-set-key {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 12px;
}
.btn-set-key:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main grid ── */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  overflow: hidden;
  height: calc(100vh - var(--topbar-h) - var(--backend-h) - var(--footer-h));
}

/* ── Panels ── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.panel-right { border-right: none; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.panel-title { font-weight: 600; font-size: 13px; color: var(--text); }
.plan-meta   { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* ── Intent textarea ── */
.intent-input {
  width: 100%;
  background: var(--bg3);
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.55;
  flex-shrink: 0;
}
.intent-input:focus { border-bottom-color: var(--accent); }
.intent-input::placeholder { color: var(--text-dim); }
.intent-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Button row ── */
.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-run    { background: var(--run);    color: #fff; }
.btn-run:not(:disabled):hover    { background: var(--run-hover); }
.btn-cancel { background: var(--cancel); color: #fff; }
.btn-cancel:not(:disabled):hover { background: var(--cancel-hover); }
.hint { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* ── Subpanels ── */
.subpanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--border);
  min-height: 0;
}
.subpanel-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 6px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Task list ── */
.task-list {
  list-style: decimal inside;
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
}
.task-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 14px;
  border-left: 3px solid transparent;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}
.task-list li:hover { background: var(--bg3); }
.task-list li.running { border-left-color: var(--warn); background: rgba(245,166,35,0.06); }
.task-list li.done    { border-left-color: var(--ok);   background: rgba(62,207,142,0.04); }
.task-list li.fail    { border-left-color: var(--err);  background: rgba(224,92,92,0.06); }
.task-list .empty     { color: var(--text-dim); font-style: italic; list-style: none; }

.tid { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }
.cmd { font-family: var(--font-mono); font-size: 12px; color: var(--text); word-break: break-all; }
.exp { font-size: 11px; color: var(--text-dim); font-style: italic; }

/* ── Right panel layout ── */
.panel-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-right .subpanel:first-child { flex: 1.5; }
.panel-right .subpanel:last-child  { flex: 1; }

/* ── Results pane ── */
.results-pane,
.validation-pane {
  overflow-y: auto;
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty { color: var(--text-dim); font-style: italic; font-size: 13px; padding: 4px 2px; }

/* ── Result card ── */
.result-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.result-card[data-ok="true"]  { border-left: 3px solid var(--ok); }
.result-card[data-ok="false"] { border-left: 3px solid var(--err); }

.result-card .head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.result-card .id  { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }
.result-card .cmd { font-family: var(--font-mono); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-card .ec  { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-left: auto; white-space: nowrap; }
.result-card[data-ok="false"] .ec { color: var(--err); }

.result-card .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); padding: 4px 10px 0; }
.result-card pre {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px 8px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  max-height: 200px;
  overflow-y: auto;
}

/* ── Validation card ── */
.val-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.val-card[data-pass="true"]  { border-left: 3px solid var(--ok); }
.val-card[data-pass="false"] { border-left: 3px solid var(--err); }

.vhead { display: flex; align-items: center; gap: 8px; }
.vid   { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.vbadge {
  font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 10px;
}
.val-card[data-pass="true"]  .vbadge { background: rgba(62,207,142,0.15); color: var(--ok); }
.val-card[data-pass="false"] .vbadge { background: rgba(224,92,92,0.15);  color: var(--err); }

.vmeta  { font-size: 12px; color: var(--text-dim); }
.vrules { font-size: 12px; color: var(--err); font-family: var(--font-mono); }

/* ── Footer ── */
.footer {
  height: var(--footer-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Responsive: narrow viewport ── */
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .panel { border-right: none; border-bottom: 1px solid var(--border); }
}
