/* ============================================================================
   FIBER · Componentes de UI
   Botões, cards, inputs, chips, badges, carrinho, modal, toast, skeleton.
   ========================================================================== */

/* ---------- Botões ---------- */
.btn {
  --_bg: var(--fiber-red);
  --_fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  padding: 14px 22px; border-radius: var(--r-pill);
  background: var(--_bg); color: var(--_fg);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur);
  box-shadow: var(--sh-sm);
  min-height: 50px; line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn--primary { --_bg: var(--fiber-red); box-shadow: var(--sh-red); }
.btn--primary:hover { --_bg: var(--fiber-red-600); }
.btn--dark { --_bg: var(--sel-bg); --_fg: var(--sel-fg); box-shadow: var(--sh-md); }
.btn--ghost { --_bg: transparent; --_fg: var(--ink); box-shadow: none; border: 1.5px solid var(--line-2); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--light { --_bg: var(--field-bg); --_fg: var(--ink); box-shadow: var(--sh-sm); border: 1px solid var(--line); }
.btn--block { display: flex; width: 100%; }
.btn--lg { padding: 17px 26px; font-size: 16px; min-height: 56px; }
.btn--sm { padding: 9px 16px; font-size: 13px; min-height: 44px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; box-shadow: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--r-md);
  box-shadow: var(--sh-sm); border: 1px solid var(--line);
  overflow: hidden;
}
.card--flat { box-shadow: none; }
.card--pad { padding: var(--sp-5); }

/* ---------- Inputs ---------- */
.field { display: block; }
.field > label, .label {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 7px; letter-spacing: -0.01em;
}
.label .req { color: var(--red-text); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; background: var(--field-bg); border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm); padding: 14px 15px; font-size: 16px; color: var(--ink);
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--fiber-red); box-shadow: 0 0 0 4px var(--fiber-red-soft); outline: none;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7078' stroke-width='2.4' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 42px;
}
.field--error .input, .field--error .select, .field--error .textarea { border-color: var(--fiber-red); background: var(--fiber-red-soft); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field-error { font-size: 12px; color: var(--red-text); margin-top: 6px; font-weight: 600; display: none; }
.field--error .field-error { display: block; }

/* ---------- Chips / tabs ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-pill); background: var(--field-bg);
  border: 1.5px solid var(--line-2); font-weight: 600; font-size: 14px; color: var(--ink-2);
  transition: all var(--dur) var(--ease); scroll-snap-align: start; white-space: nowrap;
}
.chip { min-height: 44px; -webkit-tap-highlight-color: transparent; }
.chip > * { pointer-events: none; }   /* clique sempre cai no botão inteiro */
.chip .chip-ico { font-size: 15px; }
.chip.is-active { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); box-shadow: var(--sh-sm); }
.chip:not(.is-active):hover { border-color: var(--ink-soft); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.badge--red { background: var(--fiber-red-soft); color: var(--red-text); }
.badge--ink { background: var(--sel-bg); color: var(--sel-fg); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--muted { background: var(--bg-2); color: var(--ink-2); }

/* ---------- Stepper (quantidade + / -) ---------- */
.stepper { display: inline-flex; align-items: center; background: var(--bg); border-radius: var(--r-pill); padding: 4px; gap: 2px; border: 1px solid var(--line); }
.stepper button {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: var(--ink); background: var(--field-bg); box-shadow: var(--sh-xs);
  transition: transform var(--dur) var(--ease), background var(--dur), color var(--dur);
}
.stepper button:hover { background: var(--sel-bg); color: var(--sel-fg); }
.stepper button:active { transform: scale(0.9); }
.stepper button:disabled { opacity: 0.35; pointer-events: none; }
.stepper .qty { min-width: 34px; text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 16px; }
/* Campo de quantidade editável (aceita digitação) */
input.qty { width: 48px; background: transparent; border: 1.5px solid transparent; border-radius: 10px; padding: 4px 2px; color: var(--ink); -moz-appearance: textfield; appearance: textfield; transition: border-color var(--dur), background var(--dur); }
input.qty::-webkit-outer-spin-button, input.qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.qty:focus { outline: none; background: var(--field-bg); border-color: var(--fiber-red); box-shadow: 0 0 0 3px var(--fiber-red-soft); }
.stepper--sm button { width: 32px; height: 32px; font-size: 17px; }
.stepper--sm .qty { min-width: 26px; font-size: 14px; }
.stepper--sm input.qty { width: 40px; font-size: 14px; }

/* ---------- Swatches de cor ---------- */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 8px;
  border-radius: var(--r-pill); border: 1.5px solid var(--line-2); background: var(--field-bg);
  font-size: 13px; font-weight: 600; color: var(--ink-2); transition: all var(--dur) var(--ease);
}
.swatch .dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.28); flex: 0 0 auto; }
.swatch.is-active { border-color: var(--sel-bg); background: var(--sel-bg); color: var(--sel-fg); }
.swatch.is-active .dot { box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }

/* ---------- Modal / Sheet ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 17, 20, 0.55); backdrop-filter: blur(3px);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--dur);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--card); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-lg); max-height: 92dvh; max-width: 100%; display: flex; flex-direction: column;
  transform: translateY(100%);
  /* visibility tira a sheet fechada do caminho DEPOIS da animação: sem isso
     ela fica invisível na frente da tela engolindo cliques (desktop) */
  visibility: hidden;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open {
  transform: translateY(0); visibility: visible;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.sheet__grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 12px auto 4px; flex: 0 0 auto; }
.sheet__head { padding: 8px var(--sp-5) var(--sp-3); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.sheet__body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet__foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); background: var(--card-tint); }
.sheet__close { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 18px; color: var(--ink-soft); }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -46%) scale(0.98); width: min(520px, 92vw); border-radius: var(--r-xl); max-height: 88dvh; opacity: 0; }
  .sheet.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------- Sheet HERO: detalhe de produto com foto full-bleed ----------
   Foto encostada no topo do popup, sem molduras, cobrindo o palco quadrado.
   Controles em "liquid glass" e blueprint sutil no fundo (padrão dos decks). */
.sheet--hero .sheet__grip,
.sheet--hero .sheet__head { display: none; }
.sheet--hero .sheet__body { padding: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }

/* Palco quadrado (mais vertical): a foto cobre o quadro inteiro, borda a
   borda. Fotos de proporção extrema (caneleiras verticais, expositores
   panorâmicos) aparecem inteiras sobre o fundo limpo (.is-contain). */
.pdh__stage {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: min(66dvh, 560px);
  background: var(--media-bg); overflow: hidden; user-select: none;
}
/* blueprint tênue + glow vermelho (aparecem só ao redor de fotos contain;
   a foto em cover tapa o fundo por inteiro) */
.pdh__stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(260px 260px at 108% -12%, rgba(215, 31, 63, 0.12), transparent 70%),
    linear-gradient(rgba(23, 24, 26, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 24, 26, 0.028) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
}
.pdh__img {
  position: relative; z-index: 2; width: 100%; height: 100%;
  object-fit: cover; cursor: pointer;
  transition: opacity 0.32s var(--ease), transform 0.45s var(--ease);
}
.pdh__img.is-contain { object-fit: contain; }
/* telas baixas: encolhe o palco pra a grade de quantidades não cair fora da dobra */
@media (max-height: 760px) { .sheet--hero .pdh__stage { max-height: 42dvh; } }
.pdh__img.is-out { opacity: 0; transform: scale(0.97); }

/* Controles liquid glass: sempre claros (a foto vive em caixa clara nos 2
   temas). Receita: vidro em gradiente + borda de luz + reflexo especular
   (::before, sob o ícone) + sombra dupla, com molas suaves no toque. */
.pdh__nav, .pdh__close {
  position: absolute; z-index: 4; display: grid; place-items: center;
  color: #17181a;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.26) 50%, rgba(255, 255, 255, 0.52));
  border: 1px solid rgba(255, 255, 255, 0.85); border-radius: 50%; cursor: pointer;
  backdrop-filter: blur(20px) saturate(1.9); -webkit-backdrop-filter: blur(20px) saturate(1.9);
  box-shadow:
    0 12px 28px rgba(20, 22, 26, 0.20),
    0 2px 6px rgba(20, 22, 26, 0.10),
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1px 1px rgba(255, 255, 255, 0.30);
  transition: filter var(--dur), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow var(--dur);
}
.pdh__nav::before, .pdh__close::before {
  content: ""; position: absolute; inset: 1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 55%);
}
.pdh__nav:hover, .pdh__close:hover {
  filter: brightness(1.06); transform: scale(1.08);
  box-shadow:
    0 16px 34px rgba(20, 22, 26, 0.24),
    0 3px 8px rgba(20, 22, 26, 0.12),
    inset 0 1px 1px rgba(255, 255, 255, 1),
    inset 0 -1px 1px rgba(255, 255, 255, 0.35);
}
.pdh__nav:active, .pdh__close:active { transform: scale(0.90); }
.pdh__nav svg, .pdh__close svg { position: relative; }
.pdh__nav { width: 42px; height: 42px; top: 50%; margin-top: -21px; }
.pdh__nav--prev { left: 12px; }
.pdh__nav--next { right: 12px; }
.pdh__close { width: 36px; height: 36px; top: 12px; right: 12px; }

/* Miniaturas: barra pill de vidro flutuando sobre a base da foto */
.pdh__thumbs {
  position: absolute; z-index: 4; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px; max-width: calc(100% - 24px); overflow-x: auto;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0.44));
  border: 1px solid rgba(255, 255, 255, 0.8); border-radius: var(--r-pill);
  backdrop-filter: blur(20px) saturate(1.9); -webkit-backdrop-filter: blur(20px) saturate(1.9);
  box-shadow:
    0 12px 28px rgba(20, 22, 26, 0.16),
    0 2px 6px rgba(20, 22, 26, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1px 1px rgba(255, 255, 255, 0.30);
  scrollbar-width: none;
}
.pdh__thumbs::before {
  content: ""; position: absolute; inset: 1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(140% 90% at 50% -20%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%);
}
.pdh__thumbs::-webkit-scrollbar { display: none; }
.pdh__thumb {
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0; cursor: pointer;
  border: 1.5px solid transparent; border-radius: 50%; overflow: hidden;
  background: var(--media-bg); opacity: 0.72;
  transition: opacity var(--dur), border-color var(--dur), transform var(--dur) var(--ease);
}
.pdh__thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; display: block; }
.pdh__thumb:hover { opacity: 1; }
.pdh__thumb.is-active { opacity: 1; border-color: var(--fiber-red); transform: scale(1.08); box-shadow: 0 0 0 3px var(--fiber-red-glow); }

/* Corpo do hero: respiro generoso, eyebrow no padrão dos decks */
.pdh__body { padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.pdh__eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 800; font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--red-text);
  margin-bottom: 6px;
}
.pdh__eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--fiber-red); }
.pdh__name { font-size: 20px; line-height: 1.15; margin-bottom: 10px; }
/* preço discreto ao lado do nome no popup */
.pdh__titlerow { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; }
.pdh__titlerow .pdh__name { margin-bottom: 0; }
.pdh__titlerow { margin-bottom: 10px; }
.pdh__price { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; color: var(--ink-soft); white-space: nowrap; }
.pdh__price small { font-family: var(--font-ui); font-weight: 500; font-size: 11px; color: var(--muted); }
.pdh__meta { margin-bottom: var(--sp-4); }

@media (prefers-reduced-motion: reduce) {
  .pdh__img, .pdh__nav, .pdh__close, .pdh__thumb { transition: none; }
}

/* Checkbox de aceite com erro persistente (paridade com .field--error) */
.aceite--error { outline: 2px solid var(--fiber-red); outline-offset: 6px; border-radius: 8px; background: var(--fiber-red-soft); }

/* Título de card/sheet (mesmo papel semântico em todo o app) */
.h-card { font-size: 17px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: var(--sel-bg); color: var(--sel-fg); padding: 12px 18px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 9px;
  animation: pop var(--dur) var(--ease) both;
}
.toast .tico { width: 20px; height: 20px; border-radius: 50%; background: var(--fiber-red); display: grid; place-items: center; font-size: 12px; flex: 0 0 auto; }
.toast--ok .tico { background: var(--ok); }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, var(--line-2) 37%, var(--bg-2) 63%); background-size: 800px 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--r-sm); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--ink-soft); }
.empty .empty-ico { font-size: 42px; margin-bottom: var(--sp-3); opacity: 0.8; }
.empty h3 { font-size: 18px; margin-bottom: 6px; }

/* ---------- Divider ---------- */
.hr { height: 1px; background: var(--line); border: 0; margin: var(--sp-4) 0; }

/* ---------- Progress steps ---------- */
.steps { display: flex; align-items: center; gap: 6px; justify-content: center; }
.steps .step { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.steps .step .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-2); color: var(--muted); display: grid; place-items: center; font-size: 12px; }
.steps .step.is-done .dot { background: var(--ok); color: #fff; }
.steps .step.is-active .dot { background: var(--fiber-red); color: #fff; box-shadow: 0 0 0 4px var(--fiber-red-soft); }
.steps .step.is-active { color: var(--ink); }
.steps .bar { width: 26px; height: 2px; background: var(--line-2); border-radius: 2px; }

/* link discreto em forms (recuperação de acesso) */
.link-btn {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--info-700);
  text-decoration: underline; text-underline-offset: 3px; min-height: 44px;
}
.link-btn:hover { color: var(--fiber-red); }
