/* ────────────────────────────────────────────────────────────
   Morpheus-WASM — Phase 1 POC styling
   A clean, light, readable theme for the Basque autocomplete demo.
   ──────────────────────────────────────────────────────────── */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #1a1d23;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-glow: rgba(37, 99, 235, 0.18);
  --ghost: #b4b9c4;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 32px 18px 56px;
  line-height: 1.5;
}

.container { width: 100%; max-width: 720px; }

/* ── Header ── */
header { margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 5px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 3px 10px var(--accent-glow);
}
.brand h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.brand .ver {
  font-size: 0.62rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px; letter-spacing: 0.02em;
}
.subtitle { font-size: 0.86rem; color: var(--muted); margin-left: 45px; }
.subtitle a { color: var(--accent); text-decoration: none; }
.subtitle a:hover { text-decoration: underline; }

.mode-nav { display: flex; gap: 8px; margin-left: 45px; margin-top: 10px; }
.mode-nav-item {
  font-size: 0.8rem; font-weight: 500; text-decoration: none;
  padding: 4px 12px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.mode-nav-item:hover { border-color: var(--border-strong); color: var(--text); }
.mode-nav-item.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.03);
}

/* ── Loading panel ── */
.loading-panel { padding: 30px 26px; text-align: center; }
.loading-panel .icon-wrap {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.loading-panel .icon-wrap svg { width: 26px; height: 26px; }
.loading-panel .icon-wrap.error { background: var(--danger-soft); color: var(--danger); }
.loading-panel .icon-wrap.ready { background: var(--success-soft); color: var(--success); }
.loading-panel .icon-wrap.spin svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-panel h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 5px; }
.loading-panel .status-text { font-size: 0.85rem; color: var(--muted); margin-bottom: 18px; }
.loading-panel .status-text code {
  font-family: var(--mono); font-size: 0.8em; background: var(--surface-2);
  padding: 1px 5px; border-radius: 4px; color: var(--text);
}

/* progress bar */
.progress-wrap { max-width: 380px; margin: 0 auto 10px; }
.progress-bar {
  height: 8px; background: var(--surface-2); border-radius: 99px;
  overflow: hidden; border: 1px solid var(--border);
}
.progress-bar .fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  border-radius: 99px;
  transition: width 0.25s ease;
}
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--faint);
  font-variant-numeric: tabular-nums; margin-top: 6px;
}

/* ── Backend / info badges row ── */
.badges {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 16px;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 9px; border-radius: 99px;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.badge.ok .dot { background: var(--success); }
.badge.warn .dot { background: var(--warn); }
.badge.ok { color: var(--success); }
.badge.warn { color: var(--warn); }

/* ── Error / fallback banner ── */
.banner {
  display: none; margin-top: 16px; padding: 12px 15px;
  border-radius: var(--radius-sm); font-size: 0.82rem; line-height: 1.5;
  text-align: left;
}
.banner.show { display: block; }
.banner.error { background: var(--danger-soft); border: 1px solid rgba(220,38,38,0.25); color: #991b1b; }
.banner.warn { background: var(--warn-soft); border: 1px solid rgba(217,119,6,0.25); color: #92400e; }
.banner code { font-family: var(--mono); font-size: 0.85em; background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; }

/* ── Editor (hidden until model ready) ── */
.editor-card { overflow: hidden; }
.editor-card.hidden { display: none; }

.editor-wrapper {
  position: relative;
  border-bottom: 1px solid var(--border);
}
textarea#editor {
  display: block; width: 100%;
  min-height: 180px; padding: 18px 20px;
  font-family: var(--mono);
  font-size: 15.5px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: break-word;
  border: none; outline: none; background: transparent; resize: vertical;
  color: var(--text); caret-color: var(--accent);
  tab-size: 2;
}
textarea#editor::placeholder { color: var(--ghost); font-style: italic; }
textarea#editor::selection { background: rgba(37,99,235,0.18); }
textarea#editor.ghost-active::selection {
  color: var(--ghost); background: transparent; font-style: italic;
}
textarea#editor.ghost-active::-moz-selection {
  color: var(--ghost); background: transparent; font-style: italic;
}

/* status strip below editor */
.status-strip {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 9px 18px; background: var(--surface);
  font-size: 0.74rem; color: var(--muted);
}
.status-strip .metric { display: flex; align-items: center; gap: 5px; }
.status-strip .metric b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-strip .spacer { flex: 1; }
.status-strip .live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 0 var(--success-soft);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22,163,74,0.4); }
  70% { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

/* ── Examples ── */
.examples { padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.examples .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 600; margin-bottom: 8px; }
.examples .chips { display: flex; flex-wrap: wrap; gap: 7px; }
.examples .chip {
  font-family: var(--mono); font-size: 0.78rem;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 5px 11px; border-radius: 99px;
  cursor: pointer; transition: all 0.12s;
}
.examples .chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── Hint footer ── */
.hint {
  margin-top: 14px; font-size: 0.76rem; color: var(--faint);
  text-align: center;
}
.hint kbd {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px;
  color: var(--text);
}

/* ── Debug log (collapsible) ── */
details.debug {
  margin-top: 18px; font-size: 0.76rem; color: var(--muted);
}
details.debug summary { cursor: pointer; user-select: none; font-weight: 500; }
details.debug pre {
  margin-top: 8px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.6;
  white-space: pre-wrap; overflow-x: auto; max-height: 220px; overflow-y: auto;
  color: var(--text);
}

/* ── Responsive ── */
@media (max-width: 540px) {
  body { padding: 20px 12px 40px; }
  .subtitle { margin-left: 0; }
  textarea#editor { font-size: 14.5px; padding: 15px 16px; }
}
