/* WAPATICA STORE — catálogo mobile-first.
   Layout: cabecera fija estrecha, fila de categorías deslizable, rejilla 2 → 3 → 4 columnas; detalle en hoja inferior.
   Identidad: azul índigo de mezclilla + etiqueta colgante amarilla para el precio (la etiqueta de la prenda OG). */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --ink: #0f1830;
  --muted: #56617a;
  --line: #dbe0ec;
  --denim: #1d2b6b;
  --denim-soft: #e4e8f7;
  --tag: #ffd23f;
  --tag-ink: #1a1400;
  --wa: #0f7a43;
  --wa-ink: #ffffff;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --shadow: 0 1px 2px rgb(15 24 48 / 8%), 0 8px 24px rgb(15 24 48 / 6%);

  --display: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: 16px;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #131a2e; --ink: #e9edf6; --muted: #9aa5bd; --line: #26304a;
    --denim: #8fa6ff; --denim-soft: #1c2748; --tag: #ffd23f; --tag-ink: #1a1400;
    --wa: #25a864; --wa-ink: #04140b; --warn: #ffcf70; --warn-bg: #2d2410;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #131a2e; --ink: #e9edf6; --muted: #9aa5bd; --line: #26304a;
  --denim: #8fa6ff; --denim-soft: #1c2748; --tag: #ffd23f; --tag-ink: #1a1400;
  --wa: #25a864; --wa-ink: #04140b; --warn: #ffcf70; --warn-bg: #2d2410;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body);
}
img { max-width: 100%; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--denim); outline-offset: 2px; border-radius: 6px; }

/* ---------- cabecera */
.top { background: var(--denim); color: #fff; }
.top__in {
  max-width: 1120px; margin: 0 auto; padding: 10px var(--gutter);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: baseline; gap: 6px; color: inherit; text-decoration: none; }
.brand__name { font: 800 1.45rem/1 var(--display); letter-spacing: .02em; }
.brand__tag {
  font: 700 .68rem/1 var(--body); letter-spacing: .18em; padding: 3px 6px 2px;
  background: var(--tag); color: var(--tag-ink); border-radius: 3px;
}
.top__meta { margin: 0; font-size: .8rem; opacity: .85; letter-spacing: .02em; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .top { background: #16204a; } }
:root[data-theme="dark"] .top { background: #16204a; }

/* ---------- contenido */
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: var(--gutter); padding-block: 20px 40px; }
.intro { display: grid; gap: 10px; }
.intro h1 {
  margin: 0; font: 800 clamp(1.7rem, 6.4vw, 2.6rem)/1.02 var(--display);
  letter-spacing: -.005em; text-transform: uppercase; text-wrap: balance; max-width: 18ch;
}
.intro__sub { margin: 0; color: var(--muted); max-width: 52ch; }
.search input {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px;
}
.search input::placeholder { color: var(--muted); }

/* categorías: fila deslizable, sin barra de scroll visible */
.cats {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 4;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
  margin: 16px calc(var(--gutter) * -1) 4px; padding: 10px var(--gutter);
  background: var(--bg); scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 8px;
  font: 600 .95rem/1 var(--body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; cursor: pointer;
}
.cat__n { font: 600 .75rem/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.cat[aria-pressed="true"] { background: var(--denim); border-color: var(--denim); color: #fff; }
.cat[aria-pressed="true"] .cat__n { color: rgb(255 255 255 / 75%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cat[aria-pressed="true"] { color: #0b1020; } :root:not([data-theme="light"]) .cat[aria-pressed="true"] .cat__n { color: rgb(11 16 32 / 70%); } }
:root[data-theme="dark"] .cat[aria-pressed="true"] { color: #0b1020; }
:root[data-theme="dark"] .cat[aria-pressed="true"] .cat__n { color: rgb(11 16 32 / 70%); }

.status { margin: 8px 0 12px; color: var(--muted); font-size: .9rem; min-height: 1.4em; }

/* ---------- rejilla de productos */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; min-width: 0; text-align: left; padding: 0;
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.card:active { transform: scale(.985); }
@media (hover: hover) { .card:hover { transform: translateY(-2px); } }
.card__media { position: relative; aspect-ratio: 1; max-width: 100%; background: var(--denim-soft); }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__body { display: grid; gap: 4px; padding: 10px 12px 12px; min-width: 0; }
.card__name { margin: 0; font-weight: 650; font-size: .95rem; line-height: 1.25; overflow-wrap: anywhere; }
.card__meta { margin: 0; font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.card__flag { margin: 0; font-size: .72rem; color: var(--warn); }

/* etiqueta colgante del precio */
.tag {
  position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px;
  font: 800 .92rem/1 var(--display); letter-spacing: .01em; font-variant-numeric: tabular-nums;
  color: var(--tag-ink); background: var(--tag); padding: 7px 10px 6px 18px;
  border-radius: 4px 8px 8px 4px; transform: rotate(-3deg); box-shadow: 0 2px 6px rgb(0 0 0 / 18%);
}
.tag::before {  /* ojal de la etiqueta */
  content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--surface);
}
.tag--ask { font-family: var(--body); font-weight: 700; font-size: .75rem; }

/* sin foto: placeholder tipográfico con la categoría */
.ph {
  width: 100%; height: 100%; display: grid; place-items: center; color: var(--denim);
  font: 800 clamp(1.1rem, 5vw, 1.6rem)/1 var(--display); text-transform: uppercase; letter-spacing: .04em;
  background: repeating-linear-gradient(135deg, var(--denim-soft) 0 10px, transparent 10px 20px), var(--denim-soft);
}

.empty {
  grid-column: 1 / -1; padding: 28px 18px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface);
}
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.skeleton { aspect-ratio: .78; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

/* ---------- hoja de detalle */
.sheet { padding: 0; border: 0; background: transparent; max-width: 100%; max-height: 100%; color: var(--ink); }
.sheet::backdrop { background: rgb(8 12 24 / 55%); }
.sheet[open] {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 560px;
}
.sheet__panel {
  position: relative; background: var(--surface); border-radius: 18px 18px 0 0;
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: rise .22s ease-out;
}
@media (min-width: 640px) {
  .sheet[open] { inset: 0; margin: auto; height: fit-content; }
  .sheet__panel { border-radius: 18px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet__close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgb(0 0 0 / 55%); color: #fff; font-size: 1.5rem; cursor: pointer;
}
.gallery {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: min(100vw, 44vh, 560px); max-width: 100%;
  background: var(--denim-soft); scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery > * { flex: 0 0 100%; scroll-snap-align: center; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.sheet__body { display: grid; gap: 12px; padding: 16px var(--gutter) 20px; }
.sheet__eyebrow { margin: 0; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.sheet__title { margin: 0; font: 800 1.6rem/1.05 var(--display); text-transform: uppercase; text-wrap: balance; }
.sheet__price { margin: 0; font: 800 1.35rem/1 var(--display); font-variant-numeric: tabular-nums; }
.note { margin: 0; font-size: .85rem; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; }
.pick { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick legend { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-width: 48px; min-height: 44px; padding: 0 14px; font: 600 .95rem/1 var(--body); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--denim); background: var(--denim-soft); color: var(--denim); }
.chip:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px;
  font: 700 1.05rem/1 var(--body); color: var(--wa-ink); background: var(--wa);
  border-radius: 14px; text-decoration: none;
}
.cta[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.cta__dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgb(255 255 255 / 25%); }
.sheet__help { margin: 0; font-size: .82rem; color: var(--muted); }
.preview-msg {
  margin: 0; white-space: pre-wrap; font: .85rem/1.45 var(--mono); padding: 10px 12px;
  background: var(--denim-soft); border-radius: 10px; overflow-x: auto;
}
.sheet__code { margin: 0; font: .75rem/1 var(--mono); color: var(--muted); }

/* ---------- pie */
.foot {
  max-width: 1120px; margin: 0 auto; padding-inline: var(--gutter); padding-block: 24px 32px;
  color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); display: grid; gap: 4px;
}
.foot p { margin: 0; }
.foot a { color: var(--denim); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- etapa 1: franja de pruebas y chat web */
.demo-bar {
  margin: 0; padding: 8px var(--gutter); text-align: center;
  font: 600 .82rem/1.35 var(--body); color: var(--warn); background: var(--warn-bg);
  border-bottom: 1px solid var(--line);
}

.chat-fab {
  position: fixed; z-index: 20;
  right: calc(var(--gutter) + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px 0 16px;
  font: 700 1rem/1 var(--body); color: var(--wa-ink); background: var(--wa);
  border: 0; border-radius: 999px; cursor: pointer; box-shadow: 0 6px 20px rgb(0 0 0 / 22%);
}
.chat-fab__dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 4px rgb(255 255 255 / 25%); }
.chat-fab__badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font: 800 .75rem/1 var(--body); color: var(--tag-ink); background: var(--tag);
}
body.chat-open .chat-fab { display: none; }

.chat {
  position: fixed; z-index: 30; inset: 0; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.chat[hidden] { display: none !important; }
@media (min-width: 640px) {
  .chat {
    inset: auto calc(var(--gutter) + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) auto;
    width: 380px; height: min(600px, calc(100vh - 32px)); border: 1px solid var(--line);
    border-radius: 18px; overflow: hidden; box-shadow: 0 18px 50px rgb(0 0 0 / 28%);
    padding: 0;
  }
}
@media (max-width: 639.98px) { body.chat-open { overflow: hidden; } }

.chat__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter); background: var(--denim); color: #fff;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat__head { background: #16204a; } }
:root[data-theme="dark"] .chat__head { background: #16204a; }
.chat__who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat__avatar {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center;
  font: 800 1rem/1 var(--display); color: var(--tag-ink); background: var(--tag);
}
.chat__title { margin: 0; font: 800 1.05rem/1.1 var(--display); letter-spacing: .02em; }
.chat__sub { margin: 2px 0 0; font-size: .78rem; opacity: .85; }
.chat__close {
  width: 40px; height: 40px; flex: 0 0 auto; border: 0; border-radius: 50%;
  background: rgb(255 255 255 / 15%); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.chat__notice {
  margin: 0; padding: 8px var(--gutter); font-size: .75rem; line-height: 1.35; color: var(--muted);
  background: var(--denim-soft); border-bottom: 1px solid var(--line);
}
.chat__log {
  flex: 1 1 auto; min-height: 0; margin: 0; padding: 14px var(--gutter); list-style: none; overflow-y: auto;
  overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; background: var(--bg);
}
.msg { max-width: 82%; display: flex; }
.msg--me { align-self: flex-end; }
.msg--bot { align-self: flex-start; }
.msg__text {
  margin: 0; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: .95rem; line-height: 1.4;
}
.msg--me .msg__text { background: var(--denim); color: #fff; border-bottom-right-radius: 4px; }
.msg--bot .msg__text { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg--me .msg__text { color: #0b1020; } }
:root[data-theme="dark"] .msg--me .msg__text { color: #0b1020; }
.msg__img { width: 220px; max-width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); background: var(--denim-soft); }
.chat__typing {
  margin: 0; padding: 4px var(--gutter) 6px; font-size: .8rem; color: var(--muted); background: var(--bg);
  display: flex; align-items: center; gap: 8px;
}
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat__error { margin: 0; padding: 8px var(--gutter); font-size: .82rem; color: var(--warn); background: var(--warn-bg); }
.chat__form {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px var(--gutter);
  border-top: 1px solid var(--line); background: var(--surface);
}
.chat__form textarea {
  flex: 1 1 auto; min-width: 0; resize: none; max-height: 140px; font: inherit; font-size: 1rem; line-height: 1.35;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
}
.chat__form textarea::placeholder { color: var(--muted); }
.chat__send {
  flex: 0 0 auto; min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer;
  font: 700 .95rem/1 var(--body); color: var(--wa-ink); background: var(--wa);
}
.chat__send:disabled { opacity: .5; cursor: default; }
body:has(.chat-fab:not([hidden])) .foot { padding-bottom: 96px; }
