/* ==========================================================================
   Estilos da lojinha — MOBILE FIRST.
   A base abaixo vale para celular; os blocos @media (min-width) adaptam para
   tablet e desktop. Cores vem do brand pack via variaveis CSS injetadas no
   <head> — trocar de cliente nao exige tocar neste arquivo.
   ========================================================================== */

:root {
  --brand-primary: #8b2e2e;
  --brand-accent: #c9a227;
  --brand-bg: #fffdf9;
  --brand-text: #2b2117;
  --radius: 10px;
  --border: #e7ded2;
  --muted: #7a6a5c;
  --ok: #2f6f4e;
  --warn: #a86413;
  --err: #a32b2b;
  --shadow: 0 1px 2px rgba(43, 33, 23, 0.06), 0 8px 24px rgba(43, 33, 23, 0.05);
  --tap: 44px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* folga para a barra inferior fixa (some no desktop) */
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

img { max-width: 100%; }

a { color: var(--brand-primary); }

:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
}

/* ---------- container ---------------------------------------------------- */

.wrap {
  width: 100%;
  padding-inline: 1rem;
  margin-inline: auto;
}

.narrow {
  width: 100%;
  padding-inline: 1rem;
  margin-inline: auto;
}

/* ---------- cabecalho ---------------------------------------------------- */

header.site {
  position: sticky;
  top: 0;
  z-index: 20;
  /* com viewport-fit=cover o conteudo vai sob a notch: compensa no topo */
  padding-top: env(safe-area-inset-top, 0px);
  background: #fff;
  border-bottom: 1px solid var(--border);
}

header.site .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 56px;
  padding-block: 0.4rem;
}

/* no celular a navegacao e a barra inferior */
.top-nav { display: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  text-decoration: none;
  color: var(--brand-text);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- barra inferior (celular) ------------------------------------ */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 2px rgba(43, 33, 23, 0.04);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 0.25rem 0;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.tab.active { color: var(--brand-primary); }

.tab-icon {
  position: relative;
  display: inline-flex;
}

.tab-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- conteudo ----------------------------------------------------- */

main { padding-block: 1.25rem 3rem; }

h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }
p.lead { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.strike { text-decoration: line-through; color: var(--muted); }
.inline { display: inline-flex; gap: 0.4rem; align-items: center; }

/* ---------- aviso de nova versao (PWA) ----------------------------------- */

.update-bar {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: #2b2117;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(43, 33, 23, 0.25);
}

.update-bar[hidden] { display: none; }
.update-bar .btn { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.82rem; }

/* ---------- checkout em etapas -------------------------------------------- */

main.checkout { padding-top: 0.5rem; }

.steps {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.steps-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.steps li.current { color: var(--brand-primary); }
.steps li.current .steps-num {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.steps li.done { color: var(--ok); }
.steps li.done .steps-num {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.checkout-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
}

.checkout-head h1 { margin-bottom: 0; }
.checkout-head form { display: inline-flex; align-items: baseline; gap: 0.35rem; font-size: 0.85rem; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--brand-primary);
  text-decoration: underline;
  cursor: pointer;
}

.checkout-hint { margin-top: 1rem; font-size: 0.85rem; }

.code-input {
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-weight: 700;
}

.checkout-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ---------- passkey no checkout ------------------------------------------- */

/* Bloco so aparece quando o cliente tem credencial: nada de promessa que
   pode falhar. Fica acima do codigo, que continua visivel e utilizavel. */
.passkey-block { margin: 1.25rem 0 1.5rem; }

.passkey-status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.passkey-status[data-tone='error'] { color: var(--err); }

.passkey-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.passkey-divider::before,
.passkey-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

@media (min-width: 640px) {
  .steps li { font-size: 0.85rem; }
  .steps-num { width: 26px; height: 26px; }
}

/* ---------- carrinho ------------------------------------------------------ */

.cart-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.cart-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.7rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.cart-thumb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 96px;
  border-radius: 6px;
  background: #f7f2ea;
  overflow: hidden;
}

.cart-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.cart-info {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  align-content: start;
}

.cart-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
}

.cart-unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.cart-qty {
  display: inline-flex;
  align-items: center;
  width: max-content;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.cart-qty-value {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.cart-qty .stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.cart-side {
  display: grid;
  justify-items: end;
  gap: 0.25rem;
}

.cart-line-total {
  font-weight: 800;
  white-space: nowrap;
}

.cart-remove {
  border: 0;
  background: none;
  padding: 0.25rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.cart-summary { margin-top: 0.5rem; }

.cart-note { font-size: 0.85rem; }

.cart-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  background: var(--brand-bg);
  position: sticky;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 960px) {
  .cart-actions { position: static; max-width: 360px; margin-left: auto; }
}

/* ---------- pagina do produto (PDP) -------------------------------------- */

main.pdp {
  padding-top: 0.25rem;
  padding-bottom: 1rem;
}

.pdp-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -0.5rem;
  border-radius: 999px;
  color: var(--brand-text);
  text-decoration: none;
}

.pdp-back:hover { background: rgba(43, 33, 23, 0.06); }

.pdp-media {
  display: grid;
  place-items: center;
  max-height: 300px;
  margin: 0.25rem 0 0.75rem;
  border-radius: var(--radius);
  background: #f7f2ea;
  overflow: hidden;
}

.pdp-media .product-image {
  max-height: 300px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: transparent;
}

.pdp-title {
  font-size: 1.35rem;
  margin: 0;
}

.pdp-meta {
  margin: 0.2rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.pdp-buy-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  /* stepper fica logo depois do preco; em tela estreita ele quebra de linha */
  flex-wrap: wrap;
}

.pdp-price {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.pdp-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.stepper-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--brand-text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.stepper-btn:active { background: rgba(43, 33, 23, 0.06); }

.stepper-input {
  width: 44px;
  height: 40px;
  border: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: inherit;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pdp-stock {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--ok);
}

.pdp-stock.is-out { color: var(--err); }

.pdp-description {
  margin: 0 0 1rem;
  color: var(--brand-text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.pdp-cta {
  /* sticky: acompanha a leitura do produto e desaparece quando o rodape chega.
     fixed cobria o rodape e o botao parecia vir depois dele. */
  position: sticky;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  margin-top: 0.75rem;
  padding: 0.6rem 0;
  /* fundo solido: com gradiente o conteudo de tras aparecia atras do botao */
  background: var(--brand-bg);
  box-shadow: 0 -10px 18px -12px rgba(43, 33, 23, 0.35);
}

.pdp-cta .btn { max-width: 1080px; margin-inline: auto; }


@media (min-width: 960px) {
  .pdp-price { font-size: 2.1rem; }

  .pdp-cta {
    position: static;
    padding: 1rem 0 0;
    background: none;
    border-top: 0;
  }
  main.pdp { padding-bottom: 3rem; }
}

/* ---------- hero / carrossel --------------------------------------------- */

.hero {
  position: relative;
  background: #f2ece3;
}

.hero-track {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.hero-slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.hero-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.25rem;
  display: flex;
  justify-content: center;
  gap: 0.25rem;
}

.hero-dot {
  width: 24px;
  height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.hero-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 0 1px rgba(43, 33, 23, 0.15);
}

.hero-dot.is-active::after { background: #fff; }

@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: none; }
}

/* ---------- titulo e contadores do catalogo ------------------------------ */

.page-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 1.15rem;
  margin: 0.25rem 0 0.5rem;
}

.page-title-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.chip-count {
  font-size: 0.75rem;
  opacity: 0.75;
}

/* ---------- grade de produtos (2 colunas no celular) --------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.card .thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #f7f2ea;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: var(--muted);
  text-decoration: none;
}

.card .thumb img,
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}

.card .body {
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.card-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.card-category {
  font-size: 0.72rem;
  color: var(--muted);
}

.card-out {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(43, 33, 23, 0.85);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.thumb-fallback {
  font-size: 1.8rem;
  color: var(--muted);
}

.card .price {
  font-weight: 800;
  /* alinha os precos na base do card, mesmo com nomes de 1 ou 2 linhas */
  margin-top: auto;
}

/* pagina do produto: foto retrato em caixa quadrada */
.card .thumb.product-thumb { aspect-ratio: 1 / 1; }

.product-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #f7f2ea;
}

/* ---------- botoes ------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--brand-text); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- filtros / chips --------------------------------------------- */

.filters {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin: 0.75rem 0 1.25rem;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.chip.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

/* ---------- tabelas (viram cards no celular) ----------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

th, td {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: top;
}

th {
  background: #faf6ef;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tr:last-child td { border-bottom: 0; }

@media (max-width: 639px) {
  table,
  thead,
  tbody,
  tr,
  th,
  td { display: block; }

  thead { display: none; }

  table {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }

  tbody tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.85rem;
  }

  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
  }

  tbody tr td:last-child { border-bottom: 0; }

  tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
  }

  tbody td:empty { display: none; }

  /* celulas sem rotulo (acoes/botoes) nao reservam coluna de label */
  tbody td[data-label=""] { justify-content: flex-end; }
  tbody td[data-label=""]::before { content: none; }
}

/* ---------- formularios -------------------------------------------------- */

form.stack { display: grid; gap: 0.85rem; }

.field { display: grid; gap: 0.25rem; }

.field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 1rem; /* evita zoom automatico no iOS */
  background: #fff;
  color: inherit;
}

.field textarea { min-height: auto; }

.row-2,
.row-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.check {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.92rem;
  min-height: var(--tap);
}

.check input { margin: 0; width: 20px; height: 20px; flex: 0 0 auto; }

/* pagamento manual na pagina do pedido ------------------------------------- */
.pay-box {
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
  background: var(--brand-bg);
}
.pay-box h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.pix-code {
  width: 100%;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0.55rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  resize: vertical;
}
.pay-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.4rem 0 0.6rem; }

/* escolha da forma de pagamento, na revisao do pedido ---------------------- */
.payment-choice {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem 0.9rem;
  margin-bottom: 0.9rem;
  display: grid;
  gap: 0.5rem;
}
.payment-choice legend { font-weight: 700; font-size: 0.95rem; padding: 0 0.35rem; }
.payment-option {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  min-height: var(--tap);
}
.payment-option:has(input:checked) { border-color: var(--brand-primary); box-shadow: 0 0 0 1px var(--brand-primary) inset; }
.payment-option input { margin: 0.15rem 0 0; width: 20px; height: 20px; flex: 0 0 auto; }
.payment-option small { display: block; margin-top: 0.15rem; }
.check label { font-weight: 400; }

/* ---------- mensagens e estados ----------------------------------------- */

.flash {
  margin: 0.75rem 0;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid;
  font-size: 0.92rem;
}

.flash.success { background: #eef7f1; border-color: #b9dcc6; color: var(--ok); }
.flash.error { background: #fdeeee; border-color: #efc2c2; color: var(--err); }
.flash.info { background: #eef3fa; border-color: #c3d5ee; color: #24486f; }
.flash.warning { background: #fdf5e7; border-color: #ecd39c; color: var(--warn); }

.errors {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #efc2c2;
  border-radius: 8px;
  background: #fdeeee;
  color: var(--err);
}

.errors ul { margin: 0; padding-left: 1.1rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #f1ece3;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.paid { background: #e7f4ec; color: var(--ok); }
.badge.awaiting_payment,
.badge.pending { background: #fdf1dd; color: var(--warn); }
.badge.cancelled,
.badge.refunded { background: #f5e9e9; color: var(--err); }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* ---------- resumo de valores -------------------------------------------- */

.summary {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
}

.total-row.grand {
  margin-top: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 800;
}

.two-col { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }

/* ---------- rodape ------------------------------------------------------- */

footer.site {
  border-top: 1px solid var(--border);
  background: #fff;
  padding-block: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.footer-brand address {
  font-style: normal;
  margin-top: 0.35rem;
  line-height: 1.6;
}

.footer-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.footer-list a { color: inherit; }

.footer-base {
  margin-top: 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ---------- painel administrativo --------------------------------------- */

.admin-nav {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.admin-nav::-webkit-scrollbar { display: none; }

.admin-nav a {
  flex: 0 0 auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.admin-nav a.active {
  color: var(--brand-primary);
  box-shadow: inset 0 -2px 0 var(--brand-primary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.stat .k { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stat .v { font-size: 1.35rem; font-weight: 800; }

.support-banner {
  padding: 0.45rem;
  background: #7a1f1f;
  color: #fff;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Tablet — a partir de 640px
   ========================================================================== */

@media (min-width: 640px) {
  .wrap, .narrow { padding-inline: 1.5rem; }

  h1 { font-size: 1.75rem; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }

  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: 2fr 1fr 1fr; }

  .filters { flex-wrap: wrap; overflow: visible; }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

  /* tabelas voltam ao formato tabular */
  table { display: table; background: #fff; box-shadow: var(--shadow); border-radius: var(--radius); }
  thead { display: table-header-group; }
  tbody { display: table-row-group; }
  tr { display: table-row; }
  th, td { display: table-cell; text-align: left; padding: 0.65rem 0.8rem; }
  tbody td::before { content: none; }

  .footer-cols { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* ==========================================================================
   Desktop — a partir de 960px
   ========================================================================== */

@media (min-width: 960px) {
  .wrap { max-width: 1080px; }
  .narrow { max-width: 680px; }

  header.site .bar {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }

  .brand { max-width: none; }
  .brand-logo { width: 40px; height: 40px; }
  .brand-name { font-size: 1.05rem; }

  .top-nav {
    display: flex;
    gap: 1.4rem;
    margin-left: auto;
  }

  .top-nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
  }

  .top-nav a.active,
  .top-nav a:hover { color: var(--brand-primary); }

  .tabbar { display: none; }
  body { padding-bottom: 0; }
  .update-bar { bottom: 1rem; left: auto; right: 1rem; max-width: 420px; }

  .two-col { grid-template-columns: 1.4fr 1fr; gap: 1.5rem; }
}

/* ---------- endereço resolvido no checkout --------------------------------- */

/* Quando o cliente já tem endereço, ele aparece resumido e o formulário fica
   escondido atrás do checkbox — evita pedir de novo o que já sabemos. */
.address-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  background: #fff;
}

.address-card-body strong { display: block; margin-bottom: 0.35rem; }
.address-card-body p { margin: 0 0 0.35rem; line-height: 1.45; }

.address-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.address-fields { display: grid; gap: 0.85rem; }
.address-fields[hidden] { display: none; }

.field-hint { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* campo que ocupa a linha inteira dentro dos grids de 2/3 colunas */
.field-wide { grid-column: 1 / -1; }

/* ---------- item do pedido (miniatura + nome) ------------------------------ */

.cell-item { display: flex; align-items: center; gap: 0.7rem; text-align: left; }

.item-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.item-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.item-info { display: flex; flex-direction: column; gap: 0.15rem; text-align: left; min-width: 0; }
.item-info strong { font-weight: 600; }

/* no celular a celula do item nao usa o padrao "rotulo a esquerda, valor a
   direita": a miniatura e o nome ocupam a linha inteira, alinhados a esquerda */
@media (max-width: 639px) {
  tbody td.cell-item { justify-content: flex-start; text-align: left; }
  tbody td.cell-item::before { content: none; }
}

/* ---------- conta do cliente ---------------------------------------------- */

.account-menu { display: grid; gap: 0.75rem; margin-top: 1.25rem; }

.account-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.account-item .muted { font-weight: 400; font-size: 0.88rem; }
.account-item:hover { border-color: var(--brand-primary); }

.account-item-btn {
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.account-back { margin: 0 0 0.5rem; font-size: 0.9rem; }
.account-back a { color: var(--brand-primary); text-decoration: none; }

.address-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.85rem; }

.address-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.9rem 1rem;
}

.address-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.address-item p { margin: 0.35rem 0 0; line-height: 1.45; }

.address-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.9rem;
}

.address-item-actions form { margin: 0; }
.address-item-actions .danger { color: var(--err); }
.badge.principal { background: var(--ok); color: #fff; }

/* ---------- banners no painel --------------------------------------------- */

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.banner-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.85rem; }

.banner-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.75rem;
}

.banner-item img { border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.banner-info { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 200px; }
.banner-info .muted { font-size: 0.85rem; }
.banner-actions { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.banner-actions form { margin: 0; }
.banner-actions .danger { color: var(--err); }
.banner-preview { border: 1px solid var(--border); border-radius: 8px; object-fit: cover; }
.product-photo-preview {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: cover;
  margin-bottom: .5rem;
  background: var(--brand-bg);
}
.badge.ok { background: var(--ok); color: #fff; }

/* ---------- indicadores ---------------------------------------------------- */

.report-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin: 1rem 0;
}

.report-filter .field { margin: 0; }

.report-table { width: 100%; border-collapse: collapse; background: #fff; }
.report-table th,
.report-table td { padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); text-align: right; }
.report-table thead th { text-align: right; font-size: 0.82rem; color: var(--muted); }
.report-table thead th:first-child,
.report-table tbody th { text-align: left; }
.report-table tbody th { font-weight: 600; }
.report-table .up { color: var(--ok); }
.report-table .down { color: var(--err); }
.report-note { margin-top: 0.75rem; font-size: 0.85rem; }

/* botões de ação na linha do pedido: um por transição válida */
.btn-ghost.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--border)); }
.pedido-acoes { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

/* ---------- painel em desktop ---------------------------------------------- */

/* O painel é ferramenta de balcão: a partir de 960px as tabelas viram tabelas
   de verdade, com mais largura útil. No celular seguem o padrão de cartões. */
@media (min-width: 960px) {
  .admin-page.wrap { max-width: 1180px; }
  .admin-page .wrap { max-width: 1180px; }

  .admin-page table { display: table; width: 100%; border-collapse: collapse; background: #fff; }
  .admin-page thead { display: table-header-group; }
  .admin-page tbody { display: table-row-group; }
  .admin-page tbody tr { display: table-row; border: 0; margin: 0; border-radius: 0; }
  .admin-page table th,
  .admin-page table td {
    display: table-cell;
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .admin-page table td::before { content: none; }
  .admin-page table th { font-size: 0.8rem; color: var(--muted); font-weight: 700; }
}

/* segundo botão do cadastro de passkey fica logo abaixo do principal */
[data-passkey-phone] { margin-top: 0.5rem; }
[data-passkey-guidance] { text-align: center; }

/* detalhes do produto (país, região, teor, harmonização) vindos do legado */
.pdp-info {
  margin: 0.85rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- busca e ordenação do catálogo ------------------------------- */

.catalog-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0 0.75rem;
}

.catalog-search input[type='search'],
.catalog-search input:not([type]) {
  flex: 1 1 200px;
  min-height: var(--tap);
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 1rem;
  background: #fff;
}

.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  flex-basis: 100%;
  font-size: 0.9rem;
}

.catalog-tools .check { min-height: 0; }
.field-inline { display: flex; align-items: center; gap: 0.4rem; }
.field-inline select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- acompanhamento do pedido -------------------------------------- */

.tracking { list-style: none; margin: 0.5rem 0 1.25rem; padding: 0; }

.tracking-step {
  display: grid;
  /* data embaixo do rótulo: em 414px, lado a lado o texto quebra esquisito */
  grid-template-columns: 1fr;
  gap: 0.15rem;
  padding: 0.45rem 0;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  padding-left: 0.9rem;
  position: relative;
  color: var(--muted);
}

.tracking-dot {
  position: absolute;
  left: -7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
}

.tracking-step.is-done { color: var(--brand-text); border-left-color: var(--ok); }
.tracking-step.is-done .tracking-dot { background: var(--ok); }
.tracking-step.is-current .tracking-label { font-weight: 700; }
.tracking-date { font-size: 0.8rem; }
.tracking-label { line-height: 1.25; }
