/* =============================================================
   store-ui.css — camada ADITIVA e reutilizável da Loja Tatisky.
   Prefixo `st-`. Mesma linguagem visual de profile-ui.css:
   mesmos tokens, mesmas superfícies, mesmas bordas e sombras.
   100% compatível com CSP `style-src 'self'` (nenhum style inline).
   Inclua DEPOIS do CSS principal:
     <link rel="stylesheet" href="{{ url_for('static', filename='css/store-ui.css') }}">
   ============================================================= */

.st {
  --st-fg: var(--ink, #24171e);
  --st-fg-muted: #75636b;
  --st-surface: #fffdfa;
  --st-surface-2: var(--cream, #f5ede2);
  --st-border: var(--line, rgba(53, 27, 39, 0.17));
  --st-accent: var(--wine, #621f3d);
  --st-ok: #4f745c;
  --st-warn: #9a632f;
  --st-danger: #a23855;
  --st-radius: 22px;
  --st-gap: 18px;
  --st-shadow: 0 18px 45px rgba(54, 29, 40, 0.1);
  color: var(--st-fg);
  display: grid;
  gap: var(--st-gap);
}

/* Neutraliza limites da camada antiga sem afetar outras páginas. */
.st.product-detail { max-width: none; }
.st .product-detail-image {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
}

/* ---------- utilitários ---------- */
.st-muted { color: var(--st-fg-muted); }
.st-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.st-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-icon { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.st-nums { font-variant-numeric: tabular-nums; }

/* ---------- barra de contexto da loja ---------- */
.st-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--st-border);
  border-radius: var(--st-radius); background: var(--st-surface);
}
.st-nav__brand { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--st-fg-muted); margin-right: auto; }
.st-nav__link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; min-height: 40px; border-radius: 999px;
  font-size: 0.86rem; font-weight: 600; text-decoration: none;
  color: inherit; border: 1px solid transparent;
}
.st-nav__link:hover { background: var(--st-surface-2); border-color: var(--st-border); }
.st-nav__link[aria-current="page"] { background: color-mix(in srgb, var(--st-accent) 12%, transparent); color: var(--st-accent); }

/* voltar / breadcrumb */
.st-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  font-size: 0.86rem; font-weight: 600; color: var(--st-fg-muted); text-decoration: none;
}
.st-back:hover { color: var(--st-accent); }

/* ---------- hero editorial ---------- */
.st-hero {
  padding: 26px 22px;
  border: 1px solid color-mix(in srgb, var(--st-accent) 26%, var(--st-border));
  border-radius: var(--st-radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--st-accent) 14%, var(--st-surface)), var(--st-surface));
  box-shadow: var(--st-shadow);
  display: grid; gap: 8px;
}
.st-hero__kicker { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--st-accent); font-weight: 700; }
.st-hero__title { margin: 0; font: 400 clamp(1.8rem, 4vw, 2.7rem)/1.08 var(--serif, Georgia, serif); letter-spacing: -0.025em; }
.st-hero__text { margin: 0; max-width: 60ch; font-size: 0.94rem; line-height: 1.55; color: var(--st-fg-muted); }

/* ---------- seções e painéis ---------- */
.st-section { display: grid; gap: 12px; }
.st-section__head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; justify-content: space-between; }
.st-section__title { margin: 0; font: 400 1.45rem/1.2 var(--serif, Georgia, serif); }
.st-section__sub { margin: 0; font-size: 0.84rem; color: var(--st-fg-muted); }

.st-panel {
  padding: 18px; display: grid; gap: 14px;
  background: var(--st-surface); border: 1px solid var(--st-border);
  border-radius: var(--st-radius); box-shadow: var(--st-shadow);
}
.st-panel__title { margin: 0; font: 400 1.25rem/1.2 var(--serif, Georgia, serif); }
.st-panel__hint { margin: 0; font-size: 0.82rem; color: var(--st-fg-muted); }
.st-divider { height: 1px; background: var(--st-border); border: 0; margin: 0; }

/* ---------- grid de cards ---------- */
.st-grid { display: grid; gap: var(--st-gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.st-card {
  display: grid; align-content: start;
  background: var(--st-surface); border: 1px solid var(--st-border);
  border-radius: var(--st-radius); box-shadow: var(--st-shadow);
  overflow: hidden; text-decoration: none; color: inherit;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.st-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--st-accent) 38%, var(--st-border)); box-shadow: 0 2px 4px rgba(16, 24, 40, 0.06), 0 18px 36px -22px rgba(16, 24, 40, 0.5); }
.st-card:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 32%, transparent); }
.st-card:active { transform: translateY(-1px); }
.st-card__body { display: grid; gap: 8px; padding: 16px; }
.st-card__kicker { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--st-fg-muted); font-weight: 700; }
.st-card__title { margin: 0; font: 400 1.22rem/1.25 var(--serif, Georgia, serif); }
.st-card__text { margin: 0; font-size: 0.86rem; line-height: 1.5; color: var(--st-fg-muted); }
.st-card__foot { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }

/* mídia com proporção estável */
.st-media {
  position: relative; aspect-ratio: 4 / 3; background: var(--st-surface-2);
  border-bottom: 1px solid var(--st-border); overflow: hidden;
}
.st-media--square { aspect-ratio: 1 / 1; }
.st-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-media__ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 2.4rem; font-weight: 800; text-transform: uppercase; color: #fff;
  background: linear-gradient(135deg, var(--st-accent), color-mix(in srgb, var(--st-accent) 45%, #7c3aed));
}

/* ---------- preços ---------- */
.st-price { display: grid; gap: 2px; }
.st-price__main { font-size: 1.3rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.st-price__alt { font-size: 0.84rem; color: var(--st-fg-muted); font-variant-numeric: tabular-nums; }
.st-price--lg .st-price__main { font-size: 1.7rem; }

/* ---------- badges / status ---------- */
.st-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 650;
  border: 1px solid var(--st-border); background: var(--st-surface-2); color: var(--st-fg-muted);
  white-space: nowrap;
}
.st-badge--accent { border-color: color-mix(in srgb, var(--st-accent) 35%, var(--st-border)); background: color-mix(in srgb, var(--st-accent) 12%, transparent); color: var(--st-accent); }
.st-badge--ok { border-color: color-mix(in srgb, var(--st-ok) 35%, var(--st-border)); background: color-mix(in srgb, var(--st-ok) 12%, transparent); color: var(--st-ok); }
.st-badge--warn { border-color: color-mix(in srgb, var(--st-warn) 35%, var(--st-border)); background: color-mix(in srgb, var(--st-warn) 12%, transparent); color: var(--st-warn); }
.st-badge--danger { border-color: color-mix(in srgb, var(--st-danger) 35%, var(--st-border)); background: color-mix(in srgb, var(--st-danger) 12%, transparent); color: var(--st-danger); }

/* ---------- ações ---------- */
.st-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.st-actions--stack { flex-direction: column; align-items: stretch; }
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px; border-radius: 999px;
  font: inherit; font-weight: 650; font-size: 0.92rem;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--st-accent); background: var(--st-accent); color: #fff;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.st-btn:hover { filter: brightness(1.06); }
.st-btn:active { transform: translateY(1px); }
.st-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 32%, transparent); }
.st-btn--ghost { background: var(--st-surface); color: var(--st-fg); border-color: var(--st-border); }
.st-btn--ghost:hover { background: var(--st-surface-2); }
.st-btn--danger { background: transparent; color: var(--st-danger); border-color: color-mix(in srgb, var(--st-danger) 40%, var(--st-border)); }
.st-btn--danger:hover { background: color-mix(in srgb, var(--st-danger) 10%, transparent); }
.st-btn--block { width: 100%; }
.st-btn[disabled], .st-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* ---------- formulários ---------- */
.st-form { display: grid; gap: 18px; }
.st-fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 12px; }
.st-fieldset__legend { padding: 0; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--st-fg-muted); }
.st-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.st-field { display: grid; gap: 6px; min-width: 0; }
.st-field--wide { grid-column: 1 / -1; }
.st-field > label { font-size: 0.82rem; font-weight: 600; }
.st-form .form-field { min-width: 0; margin: 0; gap: 7px; }
.st-form .form-field > label,
.st-field > label {
  color: var(--st-fg);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.st-form .form-field small { color: var(--st-fg-muted); font-size: 0.76rem; }
.st-form .form-control {
  min-height: 46px;
  border-color: var(--st-border);
  border-radius: 12px;
  background: var(--st-surface);
}
.st-form .form-control:focus {
  border-color: var(--st-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 18%, transparent);
}
.st-field input, .st-field select, .st-field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: inherit;
  background: var(--st-surface); border: 1px solid var(--st-border); border-radius: 10px;
}
.st-field input:focus-visible, .st-field select:focus-visible, .st-field textarea:focus-visible {
  outline: none; border-color: var(--st-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 22%, transparent);
}
.st-field__hint { font-size: 0.78rem; color: var(--st-fg-muted); }
.st-field__error { font-size: 0.78rem; color: var(--st-danger); }

/* stepper de quantidade (apenas visual, altera o input existente) */
.st-stepper { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--st-border); border-radius: 999px; padding: 4px; background: var(--st-surface); }
.st-stepper__btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--st-surface-2); color: inherit; font: inherit; font-size: 1.1rem; cursor: pointer; }
.st-stepper__btn:hover { background: color-mix(in srgb, var(--st-accent) 14%, transparent); color: var(--st-accent); }
.st-stepper input { width: 62px; min-height: 38px; text-align: center; border: 0; background: transparent; font: inherit; font-variant-numeric: tabular-nums; }
.st-stepper input:focus-visible { outline: 2px solid color-mix(in srgb, var(--st-accent) 45%, transparent); border-radius: 8px; }

/* ---------- layout produto ---------- */
.st-product { display: grid; gap: var(--st-gap); align-items: start; }
@media (min-width: 900px) { .st-product { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.st-product__media { border: 1px solid var(--st-border); border-radius: var(--st-radius); overflow: hidden; background: var(--st-surface); box-shadow: var(--st-shadow); }
.st-product__info { display: grid; gap: 14px; align-content: start; }
.st-product__title { margin: 0; font: 400 clamp(2rem, 4vw, 3.25rem)/1.02 var(--serif, Georgia, serif); letter-spacing: -0.035em; }
.st-product__text { margin: 0; font-size: 0.94rem; line-height: 1.6; color: var(--st-fg-muted); }

/* ---------- carrinho / linhas de item ---------- */
.st-checkout-layout { display: grid; gap: var(--st-gap); align-items: start; }
@media (min-width: 960px) { .st-checkout-layout { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr); } }
@media (min-width: 960px) { .st-sticky { position: sticky; top: 112px; } }

.st-lines { display: grid; gap: 12px; }
.st-line {
  display: grid; gap: 10px; padding: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  border: 1px solid var(--st-border); border-radius: var(--st-radius); background: var(--st-surface);
}
.st-line__id { display: grid; gap: 3px; min-width: 0; }
.st-line__name { font-weight: 650; }
.st-line__meta { font-size: 0.8rem; color: var(--st-fg-muted); }
.st-line__qty { font-size: 0.82rem; color: var(--st-fg-muted); white-space: nowrap; }
.st-line__foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--st-border); padding-top: 10px; }

/* resumo */
.st-summary { display: grid; gap: 12px; }
.st-summary__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 0.9rem; }
.st-summary__row b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.st-summary__row--total { border-top: 1px solid var(--st-border); padding-top: 10px; }

/* ---------- pedidos ---------- */
.st-orders { display: grid; gap: 12px; }
.st-order {
  display: grid; gap: 10px; padding: 16px;
  grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  border: 1px solid var(--st-border); border-radius: var(--st-radius);
  background: var(--st-surface); box-shadow: var(--st-shadow);
  text-decoration: none; color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.st-order:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--st-accent) 34%, var(--st-border)); }
.st-order__id { font-weight: 700; letter-spacing: 0.02em; }
.st-order__meta { font-size: 0.82rem; color: var(--st-fg-muted); }
.st-order__side { display: grid; gap: 6px; justify-items: end; text-align: right; }

/* ---------- pagamento / pix ---------- */
.st-pay { display: grid; gap: var(--st-gap); justify-items: center; text-align: center; }
.st-qr {
  padding: 16px; border-radius: var(--st-radius); border: 1px solid var(--st-border);
  background: #fff; display: grid; place-items: center;
}
.st-qr img { display: block; width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; }
.st-copy { display: grid; gap: 8px; width: 100%; }
.st-copy__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem;
  padding: 12px; border-radius: 10px; border: 1px dashed var(--st-border);
  background: var(--st-surface-2); word-break: break-all; text-align: left;
}
.st-waiting { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--st-fg-muted); }
.st-waiting__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st-warn); animation: st-pulse 1.6s ease-in-out infinite; }
@keyframes st-pulse { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1); } }

/* ---------- timeline de rastreio ---------- */
.st-timeline { display: grid; gap: 0; list-style: none; margin: 0; padding: 0; }
.st-timeline__item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; position: relative; }
.st-timeline__item:last-child { padding-bottom: 0; }
.st-timeline__item::before {
  content: ""; position: absolute; left: 13px; top: 20px; bottom: 0; width: 2px; background: var(--st-border);
}
.st-timeline__item:last-child::before { display: none; }
.st-timeline__mark {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--st-border); background: var(--st-surface); color: var(--st-fg-muted); z-index: 1;
}
.st-timeline__item--done .st-timeline__mark { border-color: var(--st-ok); background: var(--st-ok); color: #fff; }
.st-timeline__item--done::before { background: color-mix(in srgb, var(--st-ok) 55%, var(--st-border)); }
.st-timeline__label { align-self: center; font-size: 0.92rem; font-weight: 600; }
.st-timeline__item:not(.st-timeline__item--done) .st-timeline__label { color: var(--st-fg-muted); font-weight: 500; }
@media (min-width: 860px) {
  .st-timeline--wide { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .st-timeline--wide .st-timeline__item { grid-template-columns: minmax(0, 1fr); text-align: center; justify-items: center; padding-bottom: 0; }
  .st-timeline--wide .st-timeline__item::before { left: 50%; right: auto; top: 13px; bottom: auto; width: 100%; height: 2px; }
  .st-timeline--wide .st-timeline__label { margin-top: 8px; }
}

/* ---------- estados: vazio / info / alerta ---------- */
.st-empty {
  display: grid; gap: 10px; justify-items: center; text-align: center;
  padding: 40px 22px; border: 1px dashed var(--st-border);
  border-radius: var(--st-radius); background: var(--st-surface);
}
.st-empty__glyph { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--st-accent) 12%, transparent); color: var(--st-accent); }
.st-empty__title { margin: 0; font-size: 1.05rem; }
.st-empty__text { margin: 0; max-width: 46ch; font-size: 0.88rem; color: var(--st-fg-muted); }

.st-note {
  display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--st-radius);
  border: 1px solid var(--st-border); background: var(--st-surface-2); font-size: 0.88rem;
}
.st-note__title { font-weight: 650; }
.st-note--info { border-color: color-mix(in srgb, var(--st-accent) 32%, var(--st-border)); background: color-mix(in srgb, var(--st-accent) 8%, transparent); }
.st-note--warn { border-color: color-mix(in srgb, var(--st-warn) 34%, var(--st-border)); background: color-mix(in srgb, var(--st-warn) 9%, transparent); }
.st-note--danger { border-color: color-mix(in srgb, var(--st-danger) 34%, var(--st-border)); background: color-mix(in srgb, var(--st-danger) 8%, transparent); }

/* ---------- modal da loja ---------- */
.st-modal { border: 0; padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; border-radius: var(--st-radius); background: var(--st-surface); color: var(--st-fg); box-shadow: 0 30px 80px -30px rgba(16, 24, 40, 0.6); }
.st-modal::backdrop { background: rgba(16, 24, 40, 0.55); }
.st-modal__inner { display: grid; gap: 14px; padding: 20px; }
.st-modal__title { margin: 0; font-size: 1.1rem; }
.st-modal__text { margin: 0; font-size: 0.88rem; color: var(--st-fg-muted); }

/* ---------- entitlements ---------- */
.st-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem;
  padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--st-border);
  background: var(--st-surface-2); word-break: break-all;
}

/* ---------- mobile ---------- */
@media (max-width: 620px) {
  .st { --st-gap: 14px; }
  .st-hero { padding: 20px 16px; }
  .st-panel { padding: 14px; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .st-line, .st-order { grid-template-columns: minmax(0, 1fr); }
  .st-order__side { justify-items: start; text-align: left; }
  .st-actions .st-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .st-card, .st-order, .st-btn { transition: none; }
  .st-card:hover, .st-order:hover, .st-card:active, .st-btn:active { transform: none; }
  .st-waiting__dot { animation: none; }
}
