/* ── App shell ─────────────────────────────────────────────────────────── */
.app-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.app-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  z-index: 10;
}

.app-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--fg-primary);
}

.nav-logo { font-size: 1.2rem; }

.nav-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.nav-tag {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #22c55e;
  font-family: var(--font-mono);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s ease-in-out infinite;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cat-btn {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 0.85rem;
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-main);
}

.cat-btn:hover { background: var(--bg-tertiary); color: var(--fg-primary); }
.cat-btn.active { background: var(--accent-dim); color: var(--accent); }

.example-queries {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.example-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.78rem;
  text-align: left;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  line-height: 1.4;
  transition: border-color 0.15s, color 0.15s;
  font-family: var(--font-main);
}

.example-btn:hover {
  border-color: rgba(245,158,11,0.3);
  color: var(--fg-secondary);
}

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

/* ── Messages ────────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 1rem;
  max-width: 760px;
}

.msg-assistant { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.msg-assistant .msg-avatar {
  background: var(--accent-dim);
  border: 1px solid rgba(245,158,11,0.25);
  color: var(--accent);
}

.msg-user .msg-avatar {
  background: var(--electric-dim);
  border: 1px solid rgba(59,130,246,0.25);
  color: var(--electric);
  font-size: 0.65rem;
}

.msg-content {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--fg-secondary);
}

.msg-user .msg-content {
  background: var(--electric-dim);
  border-color: rgba(59,130,246,0.15);
  color: var(--fg-primary);
}

.msg-content p + p { margin-top: 0.6rem; }
.msg-content strong { color: var(--fg-primary); }
.msg-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(255,255,255,0.06);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.msg-hint {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin-top: 0.5rem;
}
.msg-hint em { color: var(--accent); font-style: normal; }

/* ── Typing indicator ────────────────────────────────────────────────────── */
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.2rem 0;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Product panel ───────────────────────────────────────────────────────── */
.product-panel {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-secondary);
  max-height: 340px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: max-height 0.3s ease;
}

.product-panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.panel-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.panel-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.panel-close:hover { color: var(--fg-primary); background: rgba(255,255,255,0.05); }

.product-cards {
  display: flex;
  gap: 0;
  padding: 0;
  flex-direction: column;
}

/* ── Product card ────────────────────────────────────────────────────────── */
.product-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.product-card:hover { background: rgba(255,255,255,0.02); }
.product-card:last-child { border-bottom: none; }

.card-rank {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 28px;
  padding-top: 0.25rem;
}

.card-body { flex: 1; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.card-sku {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
}

.card-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--fg-primary);
  line-height: 1.3;
}

.card-cat {
  font-size: 0.72rem;
  color: var(--electric);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-price-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  white-space: nowrap;
}

.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

.price-unit {
  font-size: 0.72rem;
  color: var(--fg-muted);
  font-weight: 400;
}

.stock-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.in-stock { background: rgba(34,197,94,0.12); color: #22c55e; }
.low-stock { background: rgba(245,158,11,0.12); color: var(--accent); }
.out-stock { background: rgba(239,68,68,0.12); color: #ef4444; }

.lead-time {
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.specs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.spec-tag {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
}

.spec-key {
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-val {
  color: var(--fg-secondary);
  font-family: var(--font-mono);
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-secondary);
  padding: 1rem 1.5rem;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: rgba(245,158,11,0.3);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--fg-primary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  min-height: 22px;
  max-height: 150px;
}

.chat-input::placeholder { color: var(--fg-muted); }

.send-btn {
  background: var(--accent);
  border: none;
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}

.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn:not(:disabled):hover { opacity: 0.85; }
.send-btn:not(:disabled):active { transform: scale(0.95); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

.input-hint {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-align: center;
  margin-top: 0.6rem;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .chat-messages { padding: 1rem; }
  .chat-input-area { padding: 0.75rem 1rem; }
  .product-panel { max-height: 250px; }
  .card-header { flex-direction: column; }
  .card-price-group { align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 0.4rem; }
}
