/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d0d;
  --sidebar-bg:  #141414;
  --card-bg:     #1a1a1a;
  --card-hover:  #202020;
  --border:      #272727;
  --text:        #e8e8e8;
  --text-muted:  #707070;
  --text-dim:    #454545;
  --accent:      #3b82f6;
  --accent-dim:  #1d4ed8;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --radius:      10px;
  --radius-sm:   6px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w:   250px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 20px;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--card-hover); color: var(--text); }

.sidebar-section { display: flex; flex-direction: column; gap: 8px; }

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.sidebar-files { display: flex; flex-direction: column; gap: 4px; }

.sidebar-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-file-item svg { flex-shrink: 0; color: var(--accent); }
.sidebar-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.muted-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
}

/* Journey steps */
.journey-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.journey-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  transition: color 0.15s;
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.journey-step.active { color: var(--text); }
.journey-step.active .step-num { background: var(--accent); color: #fff; }
.journey-step.done   { color: var(--text-muted); }
.journey-step.done .step-num { background: var(--success); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-user { align-items: flex-end; }
.msg-assistant { align-items: flex-start; }

.msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.msg-user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-assistant .msg-bubble {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  max-width: 90%;
}

/* Wide content in assistant messages (cards, tables) */
.msg-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Dataset Cards ───────────────────────────────────────────────────────── */
.dataset-cards { display: flex; flex-direction: column; gap: 10px; }

.dataset-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}
.dataset-card:hover { border-color: var(--accent); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title { font-weight: 600; font-size: 14px; line-height: 1.4; }
.card-publisher { font-size: 12px; color: var(--text-muted); }
.card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.card-reason { font-size: 12px; color: var(--accent); font-style: italic; margin-top: 4px; }
.llm-intro { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag-dl  { border-color: var(--success); color: var(--success); }
.tag-fmt { border-color: var(--accent); color: var(--accent); }

.card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Dataset title link */
.card-title-link { color: var(--text); text-decoration: none; }
.card-title-link:hover { color: var(--accent); text-decoration: underline; }

/* Checkbox in card header */
.card-checkbox-wrap { display: flex; align-items: center; margin-left: 12px; flex-shrink: 0; }
.card-checkbox {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
  flex-shrink: 0;
}

/* Selected card highlight */
.card-selected { border-color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 8%, var(--card-bg)); }

/* Compare action bar */
.compare-bar {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; padding: 10px 14px;
  background: var(--card-bg); border: 1px solid var(--accent);
  border-radius: 8px;
}
.compare-bar-label { font-size: 13px; color: var(--text-muted); flex: 1; }

.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-success  { background: var(--success); color: #fff; }
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Match Results ───────────────────────────────────────────────────────── */
.compat-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.compat-score-ring {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.compat-score-ring svg { transform: rotate(-90deg); }

.compat-score-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.compat-details { display: flex; flex-direction: column; gap: 6px; }
.compat-title   { font-weight: 600; font-size: 15px; }

.compat-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.pill-exact   { background: rgba(34, 197, 94,  0.15); color: var(--success); }
.pill-close   { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.pill-incompat { background: rgba(239, 68,  68,  0.15); color: var(--danger); }

/* Match table */
.match-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.match-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.match-table th {
  background: var(--card-bg);
  padding: 8px 12px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.match-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.match-table tr:last-child td { border-bottom: none; }
.match-table tr:hover td { background: var(--card-hover); }

.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.score-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.score-bar-fill { height: 100%; border-radius: 4px; }

.cat-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cat-exact   { background: rgba(34, 197, 94,  0.15); color: var(--success); }
.cat-close   { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.cat-incompat { background: rgba(239, 68,  68,  0.15); color: var(--danger); }

.i14y-signal {
  font-size: 11px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Export Block ────────────────────────────────────────────────────────── */
.export-block {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-title { font-weight: 600; font-size: 14px; }
.export-desc  { font-size: 13px; color: var(--text-muted); }

.export-files { display: flex; flex-direction: column; gap: 6px; }

.export-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.export-file svg { color: var(--accent); flex-shrink: 0; }

/* ── Input Area ──────────────────────────────────────────────────────────── */
.input-wrap {
  padding: 12px 24px 18px;
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}

.input-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color 0.2s;
}
.input-box:focus-within { border-color: var(--accent); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
}
.chips:empty { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0;
  line-height: 1;
  font-size: 14px;
}
.chip-remove:hover { color: var(--danger); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
}

.btn-attach {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.btn-attach:hover { color: var(--text); }

textarea#msgInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
}

textarea#msgInput::placeholder { color: var(--text-dim); }

.btn-send {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-send:hover { background: var(--accent-dim); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

.input-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Misc helpers ────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-accent  { color: var(--accent); }
