/* ============================================================================
   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(--ink); 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: #fff; --_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: 40px; }
.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(--fiber-red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; background: #fff; border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm); padding: 14px 15px; font-size: 15px; 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(--fiber-red); 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: #fff;
  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(--ink); color: #fff; border-color: var(--ink); 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(--fiber-red-700); }
.badge--ink { background: var(--ink); color: #fff; }
.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-soft); }

/* ---------- 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: #fff; box-shadow: var(--sh-xs);
  transition: transform var(--dur) var(--ease), background var(--dur), color var(--dur);
}
.stepper button:hover { background: var(--ink); color: #fff; }
.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: #fff; 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: #fff;
  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,.12); flex: 0 0 auto; }
.swatch.is-active { border-color: var(--ink); background: var(--ink); color: #fff; }
.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; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform var(--dur) var(--ease);
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open { transform: translateY(0); }
.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; }
.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; }
}

/* ---------- 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(--ink); color: #fff; 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%, #f0f1f4 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(--muted); }
.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; }
