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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #21252f;
  --border:    #2d3142;
  --accent:    #f59e0b;
  --accent-lo: rgba(245,158,11,.10);
  --accent-li: rgba(245,158,11,.18);
  --text:      #e8eaf0;
  --text-muted:#8b8fa8;
  --text-dim:  #5c6070;
  --green:     #34d399;
  --radius:    12px;
  --radius-sm: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; flex-shrink: 0; }

.brand-name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .02em;
}
.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.badge-db {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--accent-li);
  color: var(--accent);
  border: 1px solid var(--accent-lo);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ── Chat area ─────────────────────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Welcome state ─────────────────────────────────────────────────────────── */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 40px 20px;
  animation: fadeUp .4s ease both;
}
.welcome-icon svg { width: 60px; height: 60px; opacity: .7; }
.welcome-state h2 { font-size: 20px; font-weight: 600; color: var(--text); }
.welcome-state p  { font-size: 13px; color: var(--text-muted); max-width: 360px; line-height: 1.6; }

.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lo); }

/* ── Messages ──────────────────────────────────────────────────────────────── */
.messages { display: flex; flex-direction: column; gap: 16px; }

.message {
  display: flex;
  gap: 10px;
  animation: fadeUp .3s ease both;
  max-width: 100%;
}
.message.user { flex-direction: row-reverse; }
.message.assistant { flex-direction: row; }

.message-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: 78%;
  line-height: 1.5;
  font-size: 13px;
  white-space: pre-wrap;
}
.message.user .message-bubble {
  background: var(--accent-li);
  border-color: rgba(245,158,11,.35);
  color: var(--text);
}
.message.assistant .message-bubble { color: var(--text-muted); }

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.typing-indicator .message-bubble {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 18px;
}
.dot {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite both;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .30s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Input bar ─────────────────────────────────────────────────────────────── */
.input-bar {
  padding: 12px 20px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrap {
  display: flex;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
  align-items: center;
  transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--accent); }

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px 0;
}
textarea::placeholder { color: var(--text-dim); }

.btn-send {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none;
  color: #000;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
.btn-send svg { width: 16px; height: 16px; }
.btn-send:hover { opacity: .85; }
.btn-send:disabled { opacity: .35; cursor: default; }

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

/* ── Product cards ─────────────────────────────────────────────────────────── */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
  width: 100%;
}
.product-card:hover { border-color: rgba(245,158,11,.4); }

.card-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}

.card-product-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.badge-new {
  background: var(--green);
  color: #000;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

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

.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}
.badge.family-badge    { background: var(--accent-li); color: var(--accent); border: 1px solid var(--accent-lo); }
.badge.subfamily-badge{ background: rgba(52,211,153,.1); color: var(--green); border: 1px solid rgba(52,211,153,.25); }
.badge.location-badge { background: rgba(139,143,168,.1); color: var(--text-muted); border: 1px solid var(--border); }

/* Specs grid */
.card-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.spec-item {
  background: var(--surface2);
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spec-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.spec-value { font-size: 12px; color: var(--text); font-weight: 500; }
.spec-value.empty { color: var(--text-dim); font-style: italic; }

/* Variants section */
.card-variants-section {
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variants-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.variants-summary > * { font-size: 11px; color: var(--text-muted); }
.variants-summary .vi-count { font-weight: 600; color: var(--text); }
.variants-summary .sep { color: var(--text-dim); }

.variants-table-wrap { overflow-x: auto; }
.variants-table-wrap::-webkit-scrollbar { height: 4px; }
.variants-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.variants-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.variants-table th {
  text-align: left;
  padding: 5px 10px 5px 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.variants-table td {
  padding: 6px 10px 6px 0;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(45,49,66,.5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.variants-table tr:last-child td { border-bottom: none; }
.variants-table td:first-child { color: var(--accent); font-weight: 500; }
.variants-table tr:hover td { background: var(--surface2); color: var(--text); }

/* Card links */
.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 14px;
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: all .15s;
}
.card-link svg { width: 12px; height: 12px; flex-shrink: 0; }
.card-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lo); }

/* ── Simpler no-results / error ───────────────────────────────────────────── */
.no-results-msg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .app { max-width: 100%; }
  .card-specs-grid { grid-template-columns: repeat(2, 1fr); }
  .message-bubble { max-width: 90%; }
}
