/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
input, button, select, textarea { font-family: inherit; }

/* ── Design tokens — ZAP palette ── */
:root {
  --navy:        #0d1b3e;        /* ZAP dark header */
  --navy-2:      #1a2e5a;        /* slightly lighter navy */
  --teal:        #00b4cc;        /* ZAP cyan-teal accent */
  --teal-light:  #e6f8fb;
  --teal-border: #b3e8f0;
  --bg:          #f4f6fb;        /* off-white page background */
  --surface:     #ffffff;
  --surface-2:   #f8faff;
  --border:      #e2e8f4;
  --text:        #0d1b3e;        /* navy text */
  --text-muted:  #6b7ea8;
  --text-subtle: #a8bad8;
  --accent:      #00b4cc;        /* CTA: teal */
  --accent-dark: #0099ae;
  --green:       #16a34a;
  --red:         #dc2626;
  --radius:      10px;
  --radius-sm:   7px;
  --shadow:      0 1px 4px rgba(13, 27, 62, 0.07);
  --shadow-md:   0 4px 16px rgba(13, 27, 62, 0.12);
}

/* ── Base ── */
body {
  font-family: "Rubik", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ── Header — matches ZAP dark navy bar ── */
header {
  background: var(--navy);
  color: #fff;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13, 27, 62, 0.35);
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

header p {
  font-size: 0.82rem;
  color: var(--teal);
  margin-left: auto;
  font-weight: 500;
}

/* ── Split layout ── */
main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 0.9rem;
  overflow-y: auto;
}

.left-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.right-panel {
  background: var(--surface-2);
}

/* ── Panel header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── Test selector ── */
.test-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.test-selector label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.test-selector select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.45rem;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s;
}

.test-selector select:focus {
  outline: none;
  border-color: var(--teal);
}

/* ── File upload button ── */
.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--navy-2);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  user-select: none;
}

.file-upload-btn:hover {
  background: var(--teal-light);
  border-color: var(--teal-border);
  color: var(--accent-dark);
}

.file-upload-btn svg { flex-shrink: 0; }
.file-upload-btn input[type="file"] { display: none; }

/* ── Main textarea ── */
textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.87rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 180, 204, 0.12);
  background: var(--surface);
}

/* ── Prompt resize handle ── */
.prompt-resize-handle {
  flex-shrink: 0;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s;
}

.prompt-resize-handle:hover,
.prompt-resize-handle.dragging {
  background: var(--teal-light);
}

.prompt-resize-dots {
  display: block;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s;
}

.prompt-resize-handle:hover .prompt-resize-dots,
.prompt-resize-handle.dragging .prompt-resize-dots {
  background: var(--teal);
}

/* ── Prompt editor ── */
.prompt-editor {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.prompt-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background: var(--teal-light);
  border-bottom: 1px solid var(--teal-border);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.prompt-reset-btn {
  background: none;
  border: none;
  font-size: 0.72rem;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  opacity: 0.75;
}

.prompt-reset-btn:hover { opacity: 1; text-decoration: underline; }

.prompt-editor textarea {
  width: 100%;
  height: 320px;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--surface-2);
  box-shadow: none;
  cursor: default;
  transition: background 0.2s, color 0.2s;
}

.prompt-editor textarea:focus {
  outline: none;
  box-shadow: none;
}

/* Editing state — amber accent */
.prompt-editor.editing {
  border-color: #e9a800;
}

.prompt-editor.editing .prompt-editor-header {
  background: #fff8e1;
  border-bottom-color: #f5cc5a;
  color: #9a6d00;
}

.prompt-editor.editing .prompt-reset-btn {
  color: #9a6d00;
}

.prompt-editor.editing textarea {
  background: var(--surface);
  color: var(--text);
  cursor: text;
}

/* ── Controls rows ── */
.controls-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.controls-actions {
  justify-content: space-between;
}

.controls-run {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* ── Shared input style ── */
input[type="password"],
input[type="text"] {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.87rem;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 180, 204, 0.12);
  background: var(--surface);
}

input::placeholder { color: var(--text-subtle); }

#apiKey      { flex: 1; }
#modelSelect { width: 175px; flex-shrink: 0; }

/* ── Prompt toggle button ── */
button#togglePrompt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

button#togglePrompt:hover,
button#togglePrompt.active {
  background: var(--teal-light);
  color: var(--accent-dark);
  border-color: var(--teal-border);
}

/* ── Run button — ZAP teal ── */
button#run {
  background: linear-gradient(135deg, #00b4cc, #0099ae);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(0, 180, 204, 0.35);
  letter-spacing: 0.01em;
}

button#run:hover  { opacity: 0.9; }
button#run:active { transform: scale(0.97); }
button#run:disabled {
  background: #c5cedf;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ── Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Test banner ── */
.test-banner {
  background: #fffbe6;
  border: 1.5px solid #f5cc5a;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.test-banner-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #7a5200;
}

.test-banner-legend {
  display: flex;
  gap: 1.2rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.legend-pass { color: var(--green); }
.legend-fail { color: var(--red); }

/* ── Result cards ── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--teal-border);
}

.card + .card { margin-top: 0.65rem; }

.card-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-name {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--navy);
}

.card-check { font-size: 1rem; font-weight: 700; flex-shrink: 0; }
.card-check--pass { color: var(--green); }
.card-check--fail { color: var(--red); }

.card-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.5rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--border);
}

.card-inputs-label {
  font-size: 0.72rem;
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.1rem;
}

.card-input-tag {
  display: inline-block;
  background: var(--teal-light);
  border: 1px solid var(--teal-border);
  color: var(--text-muted);
  font-size: 0.74rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.card-link {
  display: inline-block;
  margin-top: 0.3rem;
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.card-link:hover { text-decoration: underline; }

/* ── Badge ── */
.badge {
  background: var(--teal-light);
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* ── Error box ── */
.error-box {
  background: #fff5f5;
  border: 1.5px solid #fcc;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--red);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Empty state ── */
.empty-state {
  color: var(--text-subtle);
  font-size: 0.87rem;
  margin-top: 2.5rem;
  text-align: center;
}
