/* ── DESIGN TOKENS (Foundation) ── */
:root {
  /* Surface (Premium Light Mode) */
  --surface-base:    #ffffff;
  --surface-muted:   #f7f7f9; /* Subtle off-white */
  --surface-raised:  #ffffff;
  --surface-strong:  #f0f0f4;

  /* Border */
  --border-default:  #e5e5eb;
  --border-muted:    #d1d1d8;
  --border-focus:    #a0a0ab;

  /* Text */
  --text-primary:    #111111; /* Deep charcoal */
  --text-secondary:  #555555;
  --text-tertiary:   #888888;
  --text-inverse:    #ffffff;

  /* Brand */
  --brand:           #e01830; /* Vibrant Canifa Red */
  --brand-hover:     #c8102e;
  --brand-subtle:    rgba(224, 24, 48, 0.08);
  --brand-border:    rgba(224, 24, 48, 0.2);

  /* Semantic */
  --success:         #2bc270;
  --warning:         #f5a623;
  --error:           #e01830;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Spacing */
  --sp1: 2px;  --sp2: 4px;  --sp3: 6px;  --sp4: 8px;
  --sp5: 12px; --sp6: 16px; --sp7: 20px; --sp8: 24px;

  /* Typography */
  --font: 'Geist', 'Geist Fallback', system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'Geist Fallback', monospace;
  --text-xs:  13px;
  --text-sm:  14px;
  --text-md:  15px;
  --text-lg:  18px;
  --text-xl:  22px;
  --text-2xl: 48px;
  --lh-base:  1.5;

  /* Shadow (Soft & Elegant for Light Mode) */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.08);
  
  --ring: 0 0 0 1px rgba(0,0,0,0.05);
  --ring-focus: 0 0 0 3px rgba(0,0,0,0.1);
  --ring-brand: 0 0 0 3px rgba(224, 24, 48, 0.2);

  /* Motion */
  --dur-instant: 100ms;
  --dur-fast:    200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  background: var(--surface-muted);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }

/* ── FOCUS VISIBLE ── */
:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: var(--r-sm); }

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100vh;
  overflow: hidden;
  background: var(--surface-base);
}

/* ══════════════════════════════
   CHAT PANEL
══════════════════════════════ */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border-default);
  overflow: hidden;
  background: var(--surface-base);
}

/* HEADER */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp6) var(--sp8);
  border-bottom: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  gap: var(--sp7);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp5);
  flex-shrink: 0;
}
.brand-icon {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px var(--brand-subtle);
}
.brand-icon svg { width: 16px; height: 16px; fill: #fff; }
.brand-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .02em;
  white-space: nowrap;
}
.brand-dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2.4s ease infinite;
}
@keyframes pulse { 0%,100%{opacity:1; box-shadow: 0 0 0 0 rgba(43,194,112,0.4)} 50%{opacity:.7; box-shadow: 0 0 0 4px rgba(43,194,112,0)} }

.hdr-right { display: flex; align-items: center; gap: var(--sp5); }

/* INPUTS */
.field {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  height: 32px;
  padding: 0 var(--sp5);
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  transition: all var(--dur-fast) var(--ease-out);
}
.field:focus-within {
  background: var(--surface-base);
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}
.field input {
  background: transparent;
  border: none;
  outline: none;
  font: 500 var(--text-sm)/1 var(--font-mono);
  color: var(--text-primary);
  width: 110px;
}
.field input::placeholder { color: var(--text-tertiary); }
.field-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}

/* TOGGLE */
.toggle-wrap {
  display: flex; align-items: center;
  gap: var(--sp3); cursor: pointer; user-select: none;
  padding: 4px 8px;
  border-radius: var(--r-md);
  transition: background var(--dur-fast);
}
.toggle-wrap:hover { background: var(--surface-muted); }
.toggle-wrap span {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 600;
}
.toggle {
  position: relative;
  width: 36px; height: 20px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  top: 2px; left: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out);
}
.toggle input:checked + .toggle-track { background: var(--success); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--ring-focus); }

/* GHOST BUTTON */
.btn-ghost {
  height: 32px;
  padding: 0 var(--sp5);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  font: 600 var(--text-xs)/1 var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--border-muted); color: var(--text-primary); background: var(--surface-muted); }
.btn-ghost:active { background: var(--surface-strong); transform: translateY(1px); }
.btn-ghost:focus-visible { box-shadow: var(--ring-focus); outline: none; }

/* ── MESSAGES SCROLL ── */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  background: var(--surface-muted); /* Light gray bg for chat area */
}
#msgs {
  width: 100%;
  max-width: 800px;
  padding: 32px var(--sp8);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* WELCOME */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp6);
  padding: 64px var(--sp8);
  text-align: center;
}
.welcome-mark {
  width: 56px; height: 56px;
  background: #ffffff;
  border: 1px solid var(--brand-border);
  border-radius: var(--r-xl);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
}
.welcome-mark svg { width: 28px; height: 28px; fill: var(--brand); }
.welcome h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.welcome p { font-size: var(--text-md); color: var(--text-secondary); max-width: 400px; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp4);
  justify-content: center;
  margin-top: var(--sp5);
}
.chip {
  height: 36px;
  padding: 0 var(--sp6);
  background: #ffffff;
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  font: 500 var(--text-sm)/34px var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.chip:hover { 
  border-color: var(--brand-border); 
  color: var(--brand); 
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.chip:focus-visible { outline: none; box-shadow: var(--ring-brand); }

/* MSG ROW */
.msg-row { display: flex; flex-direction: column; }
.msg-row.user { align-items: flex-end; }
.msg-row.bot  { align-items: flex-start; }

.bubble {
  max-width: 80%;
  padding: var(--sp6) var(--sp7);
  font-size: var(--text-md);
  line-height: 1.6;
  animation: slideUp var(--dur-fast) var(--ease-out) both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bubble.user {
  background: var(--text-primary);
  color: #ffffff;
  border-radius: var(--r-xl) var(--r-xl) var(--r-xs) var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.bubble.bot {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl) var(--r-xl) var(--r-xl) var(--r-xs);
  box-shadow: var(--shadow-sm);
}
.msg-ts {
  margin-top: var(--sp3);
  font: 500 var(--text-xs)/1 var(--font-mono);
  color: var(--text-tertiary);
  margin-left: var(--sp2);
  margin-right: var(--sp2);
}

/* TYPING */
.typing-dots {
  display: flex; gap: 4px; align-items: center;
  padding: var(--sp4) var(--sp2);
}
.typing-dots i {
  width: 6px; height: 6px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: blink 1.4s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3; transform: scale(1)} 40%{opacity:1; transform: scale(1.2)} }

/* PRODUCT STRIP */
.product-strip {
  display: flex;
  gap: var(--sp5);
  margin-top: var(--sp6);
  overflow-x: auto;
  padding: 4px; /* for shadow */
  padding-bottom: var(--sp5);
}
.p-card {
  flex: 0 0 160px;
  background: #ffffff;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-fast) var(--ease-out);
}
.p-card:hover { 
  border-color: var(--border-muted); 
  transform: translateY(-4px); 
  box-shadow: var(--shadow-md);
}
.p-card:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.p-img { 
  aspect-ratio: 3/4; 
  background: var(--surface-muted); 
  overflow: hidden; 
}
.p-img img { 
  width: 100%; height: 100%; 
  object-fit: cover; 
  display: block; 
  transition: transform 0.5s var(--ease-out); 
}
.p-card:hover .p-img img { transform: scale(1.05); }
.p-meta { 
  padding: var(--sp5); 
  display: flex;
  flex-direction: column;
  flex: 1;
}
.p-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  margin-bottom: var(--sp4);
}
.p-price-row {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp2);
}
.p-price {
  font: 700 var(--text-md)/1 var(--font-mono);
  color: var(--text-primary);
}
.p-old {
  font-size: var(--text-xs);
  text-decoration: line-through;
  color: var(--text-tertiary);
}

/* ── INPUT BAR ── */
.inp-bar {
  padding: var(--sp6) var(--sp8);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  z-index: 10;
}
.inp-wrap {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: center;
  gap: var(--sp5);
  min-height: 52px;
  padding: var(--sp3) var(--sp4) var(--sp3) var(--sp7);
  background: #ffffff;
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-fast) var(--ease-out);
}
.inp-wrap:focus-within {
  border-color: var(--border-muted);
  box-shadow: var(--shadow-md);
}
.inp-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font: 500 var(--text-md)/1.5 var(--font);
  color: var(--text-primary);
}
.inp-wrap input::placeholder { color: var(--text-tertiary); }
.btn-send {
  width: 36px; height: 36px;
  background: var(--brand);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out);
  box-shadow: 0 2px 6px var(--brand-subtle);
}
.btn-send:hover  { background: var(--brand-hover); box-shadow: 0 4px 12px var(--brand-border); }
.btn-send:active { transform: scale(.95); }
.btn-send:focus-visible { outline: none; box-shadow: var(--ring-brand); }
.btn-send svg { width: 16px; height: 16px; fill: #fff; }

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface-muted); /* slightly off-white */
  border-left: 1px solid var(--border-default);
  overflow: hidden;
}
.sb-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp6) var(--sp7);
  border-bottom: 1px solid var(--border-default);
  background: #ffffff;
  flex-shrink: 0;
}
.sb-hdr-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .02em;
}
.sb-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp7);
  display: flex;
  flex-direction: column;
  gap: var(--sp6);
}

/* SIDEBAR CARD */
.sc {
  background: #ffffff;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--sp6);
  box-shadow: var(--shadow-sm);
}
.sc-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: var(--sp5);
  display: flex;
  align-items: center;
  gap: var(--sp3);
}
.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp4) 0;
  border-bottom: 1px solid var(--border-default);
  font-size: var(--text-sm);
}
.sc-row:last-child { border-bottom: none; padding-bottom: 0; }
.sc-label { color: var(--text-secondary); font-weight: 500; }
.sc-val {
  font: 600 var(--text-sm)/1 var(--font-mono);
  color: var(--text-primary);
}

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--sp4);
  border-radius: var(--r-sm);
  font: 700 11px/1 var(--font);
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-brand { background: var(--brand-subtle); color: var(--brand); }
.badge-green { background: rgba(43,194,112,.15); color: #209353; }
.badge-amber { background: rgba(255,159,10,.15); color: #c47600; }

/* PERF GRID */
.perf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp4); }
.perf-cell {
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: var(--sp5);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.perf-val {
  display: block;
  font: 700 20px/1 var(--font-mono);
  color: var(--brand);
  margin-bottom: var(--sp3);
}
.perf-lbl { font-size: var(--text-xs); font-weight: 600; color: var(--text-tertiary); letter-spacing: .02em; text-transform: uppercase; }

/* PROMPT EDITOR */
.ptabs { display: flex; gap: var(--sp3); margin-bottom: var(--sp5); }
.ptab {
  flex: 1;
  height: 32px;
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  font: 600 var(--text-xs)/1 var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast);
  letter-spacing: .02em;
}
.ptab:hover { border-color: var(--border-muted); background: var(--surface-strong); }
.ptab.active { background: var(--text-primary); border-color: var(--text-primary); color: #fff; }
.ptab:focus-visible { outline: none; box-shadow: var(--ring-focus); }

.ptarea {
  width: 100%;
  height: 200px;
  background: #ffffff;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: var(--sp5);
  font: 500 var(--text-xs)/1.6 var(--font-mono);
  color: #005cc5; /* Code blue */
  resize: vertical;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.ptarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-subtle); }

.btn-primary {
  width: 100%;
  margin-top: var(--sp6);
  height: 36px;
  background: var(--brand);
  border: none;
  border-radius: var(--r-sm);
  font: 600 var(--text-sm)/1 var(--font);
  color: #fff;
  cursor: pointer;
  letter-spacing: .02em;
  transition: all var(--dur-fast) var(--ease-out);
  box-shadow: 0 2px 6px var(--brand-subtle);
}
.btn-primary:hover  { background: var(--brand-hover); box-shadow: 0 4px 12px var(--brand-border); }
.btn-primary:active { transform: translateY(1px); box-shadow: none; }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring-brand); }

/* DIVIDER */
.divider {
  height: 1px;
  background: var(--border-default);
  margin: 0 calc(-1 * var(--sp6));
}
