/* ShoppingGPT — modern UI
   Custom design tokens, no framework. Optimized for both dark and light modes. */

:root {
  --bg-0: #0b0d12;
  --bg-1: #11141b;
  --bg-2: #161a23;
  --bg-3: #1d2230;
  --line: #232838;
  --line-strong: #2c3245;
  --text: #e8ebf2;
  --text-muted: #9aa3b8;
  --text-dim: #6c7388;
  --accent: #7c5cff;
  --accent-2: #ff6ec7;
  --accent-soft: rgba(124, 92, 255, 0.18);
  --success: #2bd4a3;
  --warning: #ffb547;
  --danger: #ff5c7c;
  --bubble-user: linear-gradient(135deg, #7c5cff 0%, #ff6ec7 100%);
  --bubble-assistant: var(--bg-2);
  --shadow-1: 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="light"] {
  --bg-0: #f6f7fb;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #f1f3f9;
  --line: #e6e8ef;
  --line-strong: #d1d6e2;
  --text: #1a1d28;
  --text-muted: #5b6479;
  --text-dim: #8a90a3;
  --accent-soft: rgba(124, 92, 255, 0.12);
  --bubble-assistant: #ffffff;
  --shadow-1: 0 2px 8px rgba(15, 18, 28, 0.06);
  --shadow-2: 0 16px 40px rgba(15, 18, 28, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 110, 199, 0.08), transparent 60%),
    var(--bg-0);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-muted);
}

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.badge--ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  height: 100dvh;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.brand__mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-1);
}
.brand__name { font-weight: 700; letter-spacing: -0.01em; }
.brand__tag { font-size: 12px; color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: transform var(--transition), background var(--transition),
              border-color var(--transition), box-shadow var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--bubble-user);
  color: white;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.32);
}
.btn--primary:hover { box-shadow: 0 10px 24px rgba(124, 92, 255, 0.42); }

.new-chat { width: 100%; }

.sidebar__section h3 {
  margin: 0 0 var(--space-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 600;
}

.quick-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quick {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  transition: background var(--transition), border-color var(--transition);
}
.quick:hover {
  background: var(--bg-3);
  border-color: var(--line-strong);
}

.sidebar__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
  background: var(--bg-3);
  color: var(--text);
}

#themeToggle .icon-moon { display: none; }
html[data-theme="light"] #themeToggle .icon-sun { display: none; }
html[data-theme="light"] #themeToggle .icon-moon { display: block; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(43, 212, 163, 0.18);
}
.status-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 92, 124, 0.2);
}

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-0);
}

.chat__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  background:
    linear-gradient(180deg, rgba(124, 92, 255, 0.05), transparent 70%);
}
.chat__title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat__eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  background: var(--accent-soft);
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 999px;
}
.chat__title p { margin: 6px 0 0; font-size: 13px; max-width: 56ch; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  scroll-behavior: smooth;
}

.msg {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: var(--space-3);
  align-items: flex-start;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
  animation: msgIn 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg__avatar {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--bg-3);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
}
.msg--user .msg__avatar {
  background: var(--bubble-user);
  color: white;
}
.msg--assistant .msg__avatar::before {
  content: ""; width: 18px; height: 18px; display: block;
  background: linear-gradient(135deg, #7c5cff, #ff6ec7);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M5 7h10l-1 9a2 2 0 0 1-2 1.8H8a2 2 0 0 1-2-1.8Z M7.5 7V5a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='black' stroke-width='1.6'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M5 7h10l-1 9a2 2 0 0 1-2 1.8H8a2 2 0 0 1-2-1.8Z M7.5 7V5a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='black' stroke-width='1.6'/></svg>") center/contain no-repeat;
}

.msg__body { min-width: 0; }
.msg__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 6px;
}
.msg__role { font-weight: 600; font-size: 13.5px; }

.msg__content {
  background: var(--bubble-assistant);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-1);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg--user .msg__content {
  background: var(--bubble-user);
  border-color: transparent;
  border-radius: var(--radius-lg);
  border-top-right-radius: 4px;
  color: white;
}
.msg--user { grid-template-columns: 1fr 36px; }
.msg--user .msg__avatar { order: 2; }
.msg--user .msg__body { text-align: right; }
.msg--user .msg__meta { justify-content: flex-end; }
.msg--user .msg__content { display: inline-block; text-align: left; }

.msg__content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
}
.msg__content strong { color: var(--text); }
.msg__content a { color: var(--accent); }

.msg__products {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.product-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-2);
}
.product-card__img {
  height: 120px;
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 70%),
    var(--bg-3);
  position: relative;
}
.product-card__img::after {
  content: attr(data-glyph);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.product-card__body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-card__name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.product-card__price { font-weight: 600; color: var(--accent); }
.product-card__stock { font-size: 12px; color: var(--text-muted); }
.product-card__stock.is-low { color: var(--warning); }
.product-card__stock.is-out { color: var(--danger); }

.composer {
  padding: var(--space-4) var(--space-6) var(--space-5);
  border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, transparent, rgba(11, 13, 18, 0.6));
}
html[data-theme="light"] .composer {
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.6));
}
.composer form { max-width: 880px; margin: 0 auto; }

.composer__field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-2);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 10px 10px 10px 18px;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
  position: relative;
}
.composer__field::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.composer__field:focus-within { box-shadow: 0 10px 30px rgba(124, 92, 255, 0.18); }
.composer__field:focus-within::after { opacity: 1; }

.composer textarea {
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 8px 0;
  max-height: 220px;
}
.composer textarea::placeholder { color: var(--text-dim); }

.composer__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 2px;
}

.btn--send {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bubble-user);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 6px 14px rgba(124, 92, 255, 0.32);
}
.btn--send:disabled {
  background: var(--bg-3);
  color: var(--text-dim);
  box-shadow: none;
  cursor: not-allowed;
}

.composer__hint {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 8px;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-3);
  border-radius: 12px;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.empty {
  margin: auto;
  max-width: 720px;
  padding: var(--space-6) var(--space-4);
  width: 100%;
}
.empty__hero { text-align: center; margin-bottom: var(--space-6); }
.empty__kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
  font-weight: 600;
}
.empty h2 {
  font-size: 30px;
  letter-spacing: -0.025em;
  margin: 0 0 10px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 110%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.empty p { margin: 0 auto; color: var(--text-muted); max-width: 52ch; }

.empty__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: var(--space-5);
}
.suggestion {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text);
  transition: transform var(--transition), border-color var(--transition),
              background var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.suggestion::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--transition);
}
.suggestion:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--bg-2);
  box-shadow: var(--shadow-1);
}
.suggestion:hover::before { opacity: 1; }
.suggestion__tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.suggestion__title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.suggestion__hint {
  font-size: 12.5px;
  color: var(--text-dim);
}

.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 600px) {
  .chat__header { padding: var(--space-3) var(--space-4); }
  .messages { padding: var(--space-4); }
  .composer { padding: var(--space-3) var(--space-4) var(--space-4); }
}
