:root {
  --primary-color: #1f6feb;
  --bg-deep: #0b0d12;
  --bg-panel: rgba(255, 255, 255, 0.05);
  --bg-panel-strong: rgba(255, 255, 255, 0.09);
  --border-soft: rgba(255, 255, 255, 0.10);
  --text-main: #eef1f6;
  --text-dim: #9aa3b2;
  --radius: 18px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 20% -10%, color-mix(in srgb, var(--primary-color) 18%, transparent), transparent 55%), var(--bg-deep);
}

/* ---------- Header ---------- */
.storefront-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.storefront-header img.logo {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover;
  background: var(--bg-panel-strong);
}

.storefront-header .store-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}

.cart-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-color);
  color: #fff;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

/* ---------- Chat feed ---------- */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary-color) 55%, transparent) transparent;
}

.chat-feed::-webkit-scrollbar { width: 6px; }
.chat-feed::-webkit-scrollbar-track { background: transparent; }
.chat-feed::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary-color) 55%, transparent);
  border-radius: 999px;
}
.chat-feed::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* audio message bubble */
.bubble.audio-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bubble.audio-bubble .mic-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  opacity: .8;
}

.bubble-row { display: flex; }
.bubble-row.user { justify-content: flex-end; }
.bubble-row.model { justify-content: flex-start; }
.bubble-row.carousel-row { width: 100%; justify-content: flex-start; }

.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  unicode-bidi: plaintext;
  text-align: start;
}

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

.bubble-row.model .bubble {
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(10px);
}

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity:.4 } 40% { transform: translateY(-4px); opacity:1 } }

/* ---------- Product carousel ---------- */
.carousel {
  display: flex;
  gap: 10px;
  width: 100%;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.carousel::-webkit-scrollbar { display: none; }

.product-card {
  scroll-snap-align: start;
  flex: 0 0 148px;
  width: 148px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.product-card img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  cursor: zoom-in;
  background: #14161c;
  display: block;
}

.product-img-wrap { position: relative; }

.img-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-nav-btn.prev { left: 4px; }
.img-nav-btn.next { right: 4px; }

.img-dots {
  position: absolute;
  bottom: 5px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 3px;
}
.img-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
}
.img-dot.active { background: #fff; }

.product-card .info { padding: 8px 9px 10px; }
.product-card .name { font-size: 12.5px; font-weight: 600; margin: 0 0 3px; line-height: 1.25; }
.product-card .price { font-size: 13px; font-weight: 700; color: var(--primary-color); margin: 0 0 6px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.variant-group { margin-bottom: 4px; }
.variant-group-label {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.chip {
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-main);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10.5px;
  cursor: pointer;
}
.chip.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }

.add-to-cart-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 7px 0;
  background: var(--primary-color);
  color: #fff;
  font-weight: 600;
  font-size: 11.5px;
  cursor: pointer;
}

/* ---------- Interactive buttons ---------- */
.suggestion-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.suggestion-btn {
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  background: transparent;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; touch-action: pan-y; }
.lightbox[hidden] { display: none; }

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  z-index: 101;
}
.lightbox-nav-btn:hover { background: rgba(255,255,255,.28); }
.lightbox-nav-btn:not(.next) { left: 16px; }
.lightbox-nav-btn.next { right: 16px; }

/* ---------- Composer ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
}

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--bg-panel-strong);
  color: var(--text-main);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 17px;
}
.icon-btn.recording { background: #d9363e; border-color: #d9363e; color: #fff; }

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 100px;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: var(--bg-panel-strong);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: var(--font-ui);
}
.composer textarea:focus { outline: 2px solid var(--primary-color); }

.recaptcha-disclosure {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 12px 6px;
}
.recaptcha-disclosure a { color: var(--text-dim); }

/* Google's default reCAPTCHA v3 badge is position:fixed bottom-right and
   collides with the composer on mobile. Hiding it is allowed as long as
   the required attribution text (above) is shown somewhere on the page. */
.grecaptcha-badge { visibility: hidden !important; }

.send-btn {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  border: none; background: var(--primary-color); color: #fff;
  font-size: 16px; cursor: pointer;
}

.image-preview-strip {
  display: flex; gap: 6px; padding: 0 12px 6px;
}
.image-preview-strip img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }

/* ---------- Cart drawer ---------- */
.cart-drawer {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end;
}
.cart-drawer[hidden] { display: none; }
.cart-sheet {
  width: 100%; max-height: 78vh; overflow-y: auto;
  background: #14161c;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 560px;
}
.cart-sheet h3 { margin: 0 0 10px; }
.cart-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.cart-total-row { display: flex; justify-content: space-between; font-weight: 700; padding-top: 10px; font-size: 15px; }
.close-drawer { float: right; background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }

.wa-cta {
  display: block; text-align: center; margin-top: 14px;
  background: #25D366; color: #08210f; font-weight: 700;
  padding: 12px; border-radius: 12px; text-decoration: none;
}
.qr-wrap { text-align: center; margin-top: 12px; }
.qr-wrap img { width: 160px; height: 160px; border-radius: 10px; background: #fff; padding: 8px; }

.checkout-btn {
  width: 100%;
  margin-top: 14px;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: var(--primary-color);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.checkout-btn:disabled { opacity: .4; cursor: not-allowed; }

.cart-remove-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.cart-remove-btn:hover { color: #f27e7e; }

.checkout-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.checkout-form label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 10px 0 4px;
}
.checkout-form input, .checkout-form textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-panel-strong);
  color: var(--text-main);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font-ui);
  resize: none;
}
.checkout-form input:focus, .checkout-form textarea:focus { outline: 2px solid var(--primary-color); }
.checkout-note { font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; }
.checkout-error { font-size: 12.5px; color: #f27e7e; min-height: 16px; margin: 0 0 4px; }
