/* ==================================================================
   Componentes compartilhados.

   Regras que vem da vitrine do cliente final:
     - separacao por borda de 2px, nao por sombra
     - fundo suave e SEMPRE cinza; cor entra em preenchimento solido,
       borda ou texto — nunca como veu translucido
     - peso 700 em botoes e rotulos, 800 em titulos
   ================================================================== */

/* ------------------------------------------------------------------ Marca */

/* Só a palavra "ZapPedido", com Z e P maiusculos — a grafia da marca.
   O 900 fica: e o peso do proprio logotipo. O tracking e mais solto que o do
   nome da loja na vitrine porque ali o texto e todo em caixa alta; com
   minusculas, -0.045em fecharia demais as letras. */
.logo {
  display: inline-block;
  flex-shrink: 0;
  font-weight: 900;
  font-size: clamp(1.32rem, 3.4vw, 1.6rem);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--brand);
  white-space: nowrap;
  user-select: none;
}

/* ------------------------------------------------------------------ Botoes */

/* Botao chapado, como o `<Button>` padrao da vitrine: cor cheia, sem sombra
   dura e sem animacao de afundar. Reagir no hover ja basta. */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.3rem;
  border: var(--bw) solid var(--btn-bd);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  text-align: center;
  /* Sem isto o rotulo quebra em duas linhas e estoura a altura do cabecalho
     em telas estreitas. Quem precisa quebrar usa `.btn-wrap`. */
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), opacity var(--t);
}

.btn-wrap {
  white-space: normal;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bd: transparent;
  --btn-bg: var(--brand);
  --btn-fg: var(--on-brand);
}

.btn-primary:hover:not(:disabled) {
  --btn-bg: #b81212;
}

.btn-outline {
  --btn-bg: var(--surface);
  --btn-bd: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  --btn-bg: var(--bg-tint);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  --btn-fg: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
}

.btn-danger {
  --btn-bg: var(--surface);
  --btn-bd: var(--danger);
  --btn-fg: var(--danger-ink);
}

.btn-danger:hover:not(:disabled) {
  --btn-bg: var(--bg-tint);
}

.btn-lg {
  min-height: 56px;
  padding: 1rem 1.9rem;
  font-size: 1.02rem;
}

.btn-sm {
  min-height: 38px;
  padding: 0.35rem 0.9rem;
  font-size: 0.84rem;
  gap: 0.35rem;
  border-radius: var(--r-md);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  min-height: 42px;
  width: 42px;
  flex-shrink: 0;
  padding: 0;
  border-radius: var(--r-md);
}

/* Estado de carregamento */
.btn[data-loading='true'] {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn[data-loading='true']::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--btn-fg);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ Campos */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

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

.input,
.select,
.textarea {
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: var(--bw) solid var(--surface-3);
  border-radius: var(--r-md);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  padding-right: 2.6rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-3);
}

.field-error {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--danger);
}

/* ------------------------------------------------------------------ Superficies */

.card {
  background: var(--surface);
  border: var(--bw) solid var(--border);
  border-radius: var(--r-lg);
  padding: clamp(1.25rem, 3vw, 1.9rem);
}

.panel {
  background: var(--surface);
  border: var(--bw) solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.3rem;
  border-bottom: var(--bw) solid var(--border);
  background: var(--bg-tint);
}

.panel-head h2,
.panel-head h3 {
  font-size: 1rem;
  font-weight: 800;
}

.panel-body {
  padding: 1.3rem;
}

/* ------------------------------------------------------------------ Selos

   Preenchimento solido com texto branco, como o contador do carrinho e o selo
   de posicao dos mais vendidos. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.26rem 0.65rem;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.73rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-brand { background: var(--brand); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-accent { background: var(--accent); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-info { background: var(--surface-3); color: var(--text-2); }

/* Pilula de saldo. Verde enquanto ha melhorias, laranja quando acabam —
   nunca vermelho, que aqui e a cor da marca e leria como erro. */
.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: var(--r-full);
  background: var(--success);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.86rem;
  white-space: nowrap;
  transition: background var(--t);
}

.credits-pill[data-empty='true'] {
  background: var(--accent);
}

@media (max-width: 560px) {
  .credits-pill {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }
}

/* ------------------------------------------------------------------ Avisos

   Fundo branco com borda colorida de 2px — sem lavado por cima. */

.notice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 1.05rem;
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text-2);
  border: var(--bw) solid var(--border-strong);
}

.notice-error { border-color: var(--danger); color: var(--danger-ink); }
.notice-success { border-color: var(--success); color: var(--success-ink); }
.notice-warning { border-color: var(--warning); color: var(--warning); }

.notice-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.4;
}

/* ------------------------------------------------------------------ Toast */

#toasts {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(440px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1.05rem;
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: toast-in 300ms var(--ease-out) both;
}

.toast[data-type='error'] { background: #b91c1c; color: #fff; }
.toast[data-type='success'] { background: var(--success-strong); color: #fff; }

.toast.is-leaving {
  animation: toast-out 200ms var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* ------------------------------------------------------------------ Modal */

dialog.modal {
  width: min(520px, calc(100vw - 2rem));
  padding: 0;
  border: var(--bw) solid var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-xl);
}

dialog.modal::backdrop {
  background: rgba(3, 7, 18, 0.55);
}

dialog.modal[open] {
  animation: modal-in 240ms var(--ease-out) both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.3rem 1.4rem 0.5rem;
}

.modal-head h3 { font-size: 1.12rem; }
.modal-body { padding: 0.5rem 1.4rem 1rem; }

.modal-foot {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 0.75rem 1.4rem 1.4rem;
}

/* ------------------------------------------------------------------ Comparador antes/depois */

.compare {
  /* <zp-compare> e elemento customizado: sem isto nasce inline e colapsa. */
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--media-bg);
  user-select: none;
  touch-action: pan-y;
  isolation: isolate;
}

.compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.compare-after {
  clip-path: inset(0 0 0 var(--pos, 50%));
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  z-index: 3;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.compare-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 56px;
  height: 100%;
  cursor: ew-resize;
}

.compare-range::-moz-range-thumb {
  width: 56px;
  height: 400px;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos, 50%);
  width: 3px;
  margin-left: -1.5px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  z-index: 2;
  pointer-events: none;
}

.compare-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #030712;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.compare-label {
  position: absolute;
  top: 0.65rem;
  z-index: 2;
  padding: 0.25rem 0.65rem;
  border-radius: var(--r-full);
  background: rgba(3, 7, 18, 0.7);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.compare-label-before { left: 0.65rem; }
.compare-label-after { right: 0.65rem; }

.compare-range:focus-visible ~ .compare-handle {
  box-shadow: 0 0 0 3px var(--brand);
}

/* ------------------------------------------------------------------ Carregando */

.skeleton {
  background: linear-gradient(
    100deg,
    var(--surface-2) 30%,
    var(--surface-3) 50%,
    var(--surface-2) 70%
  );
  background-size: 240% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-md);
}

@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ------------------------------------------------------------------ Estado vazio */

.empty {
  display: grid;
  place-items: center;
  gap: 0.55rem;
  padding: clamp(2rem, 7vw, 3.5rem) 1.25rem;
  text-align: center;
  color: var(--text-2);
}

.empty-emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.empty h3 {
  font-size: 1.06rem;
  color: var(--text);
}

.empty p {
  max-width: 34ch;
  font-size: 0.92rem;
}

/* ------------------------------------------------------------------ Tabela */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Largura minima folgada: com 620px as colunas ficavam tao estreitas que o
   e-mail quebrava em quatro linhas. Aqui a tabela rola na horizontal, que e o
   comportamento esperado de um painel no celular. */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 880px;
}

table.data th {
  text-align: left;
  padding: 0.7rem 0.9rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: var(--bw) solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 0.8rem 0.9rem;
  border-bottom: var(--bw) solid var(--border);
  vertical-align: middle;
}

table.data tbody tr:hover {
  background: var(--bg-tint);
}

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

/* ------------------------------------------------------------------ Divisor */

.divider {
  height: var(--bw);
  background: var(--border);
  border: 0;
}

