/* Base y componentes compartidos por la tienda y el admin. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); line-height: 1.2; font-weight: 800; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4, p, li, td, strong { overflow-wrap: break-word; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
ul, ol { margin: 0; padding: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
/* <main> recibe foco al navegar (para lectores de pantalla), sin dibujar un borde. */
#main:focus, #main:focus-visible { outline: none; }

.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;
}
.skip-link {
  position: absolute; left: var(--s-2); top: -100px; z-index: 100;
  background: var(--surface); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
}
.skip-link:focus { top: var(--s-2); }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.stack > * + * { margin-top: var(--s-3); }
.stack-lg > * + * { margin-top: var(--s-5); }
.row { display: flex; align-items: center; gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  border: 2px solid transparent; border-radius: var(--r-sm);
  font-weight: 700; font-size: var(--fs-md); line-height: 1.1; text-decoration: none;
  cursor: pointer; touch-action: manipulation;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: var(--primary-tint); }
.btn-ghost { background: transparent; color: var(--primary); padding: 0 var(--s-3); }
.btn-ghost:hover { background: var(--primary-tint); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] { color: var(--danger); }

/* ---------------------------------------------------------- formularios */
.field { display: grid; gap: var(--s-1); }
.field label, .field .label { font-weight: 700; font-size: var(--fs-sm); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-2); }
.field .error { font-size: var(--fs-sm); color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: var(--s-2) var(--s-3);
  border: 2px solid var(--border-strong); border-radius: var(--r-sm); background-color: var(--surface); color: var(--ink);
}
.select { height: var(--tap); padding-top: 0; padding-bottom: 0; }
.textarea { min-height: 96px; resize: vertical; }
.h-icon { display: flex; align-items: center; gap: var(--s-2); }
[hidden] { display: none !important; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: var(--s-2); min-height: var(--tap); padding: var(--s-2) 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; font-weight: 700; }

/* ------------------------------------------------------------- chips */
.chips { display: flex; gap: var(--s-2); overflow-x: auto; padding: var(--s-1) 0; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: var(--s-1);
  min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-pill);
  border: 2px solid var(--border); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px var(--s-2);
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; line-height: 1.4; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.badge-new { background: var(--info-tint); color: var(--info); }
.badge-promo { background: var(--promo); color: var(--on-promo); }
.badge-novelty { background: var(--novelty); color: var(--on-novelty); }
.badge-featured { background: var(--primary-tint); color: var(--primary); }
.badge-warn { background: var(--approx-tint); color: var(--approx); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-ok { background: var(--primary-tint); color: var(--primary); }

/* ------------------------------------------------ etiqueta de precio (firma) */
.price-tag {
  display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  padding: 4px 10px; border: 2px solid var(--ink); border-radius: var(--r-sm);
  background: var(--surface); line-height: 1.25;
}
.price-tag .amount { font-family: var(--font-num); font-weight: 700; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.price-tag .basis { font-size: var(--fs-xs); color: var(--ink-2); }
.price-tag.is-approx { border-style: dashed; border-color: var(--approx); background: var(--approx-tint); }
.price-tag.is-approx .prefix { font-size: var(--fs-xs); font-weight: 700; color: var(--approx); text-transform: uppercase; letter-spacing: 0.04em; }
.price-tag.is-approx .basis { color: var(--approx); }

.total-box { border: 2px solid var(--ink); border-radius: var(--r-md); padding: var(--s-4); background: var(--surface); }
.total-box.is-approx { border-style: dashed; border-color: var(--approx); background: var(--approx-tint); }
.total-row { display: flex; justify-content: space-between; gap: var(--s-3); padding: 2px 0; }
.total-row.grand { font-weight: 800; font-size: var(--fs-lg); border-top: 1px solid currentColor; margin-top: var(--s-2); padding-top: var(--s-2); }
.total-row .num { white-space: nowrap; }

/* ------------------------------------------------------------- stepper */
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--primary); border-radius: var(--r-sm); background: var(--surface); }
.stepper button {
  width: var(--tap); height: calc(var(--tap) - 4px); border: 0; background: transparent; color: var(--primary);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation;
}
.stepper button:hover { background: var(--primary-tint); }
.stepper button svg { width: 20px; height: 20px; }
.stepper output { min-width: 4.5ch; padding: 0 2px; text-align: center; font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper.is-busy { opacity: 0.7; }

/* --------------------------------------------------------- superficies */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow-sm); }
.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid; }
.notice svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.notice-info { background: var(--info-tint); border-color: #B9CDEA; color: var(--info); }
.notice-warn { background: var(--approx-tint); border-color: #EBCB94; color: var(--approx); }
.notice-danger { background: var(--danger-tint); border-color: #EBB9B5; color: var(--danger); }
.notice-ok { background: var(--primary-tint); border-color: #B5D6BE; color: var(--primary); }
.notice p, .notice li { color: var(--ink); }
.notice strong { color: inherit; }

.empty { text-align: center; padding: var(--s-7) var(--s-4); }
.empty svg { width: 48px; height: 48px; margin: 0 auto var(--s-3); color: var(--ink-3); }

.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

/* ---------------------------------------------------------- dialog/sheet */
dialog.sheet {
  padding: 0; border: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 560px; max-height: min(88dvh, 820px);
  border-radius: var(--r-md); box-shadow: var(--shadow); overflow: hidden;
}
dialog.sheet::backdrop { background: var(--overlay); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--dur) var(--ease); }
@media (max-width: 639px) {
  dialog.sheet { margin: auto 0 0; max-width: none; border-radius: var(--r-md) var(--r-md) 0 0; }
}
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.sheet-body { padding: var(--s-4); overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: var(--s-2); flex-wrap: wrap; }
.sheet-foot .btn { flex: 1 1 160px; }

/* ---------------------------------------------------------------- toast */
.toasts { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: grid; gap: var(--s-2); width: min(92vw, 480px); pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); box-shadow: var(--shadow); font-weight: 600; animation: toast-in var(--dur) var(--ease); }
.toast.is-error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------ demo bar */
/* Discreta: solo existe con CONFIG.DEMO. Una línea fina que no compite con la marca. */
.demo-bar {
  display: flex; align-items: center; gap: var(--s-2); min-height: 28px;
  padding: 2px var(--s-4); background: var(--info-tint); color: var(--info); font-size: 0.75rem; font-weight: 600; line-height: 1.2;
  border-bottom: 1px solid color-mix(in srgb, var(--info) 18%, transparent);
}
.demo-bar .demo-tag { color: var(--info); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.6875rem; }
.demo-bar button { min-height: 24px; padding: 0 var(--s-2); border-radius: 6px; border: 1px solid color-mix(in srgb, var(--info) 40%, transparent);
  background: transparent; color: var(--info); font-size: 0.75rem; font-weight: 700; cursor: pointer; position: relative; }
.demo-bar button::after { content: ""; position: absolute; inset: -10px -6px; } /* área táctil ≥ 44px sin agrandar la barra */
.demo-bar button:hover { background: color-mix(in srgb, var(--info) 10%, transparent); }
.demo-bar .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 559px) { .demo-bar .demo-long { display: none; } }

.sim-label { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--info); background: var(--info-tint); border-radius: var(--r-pill); padding: 2px 8px; }

.timeline { list-style: none; display: grid; gap: var(--s-2); }
.timeline li { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-2); align-items: start; color: var(--ink-3); }
.timeline li::before { content: ""; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.timeline li.done { color: var(--ink); }
.timeline li.done::before { background: var(--primary); border-color: var(--primary); }
.timeline li.current { font-weight: 700; }

.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--s-2) var(--s-3); text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-weight: 700; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }

.loading { display: grid; place-items: center; min-height: 40vh; color: var(--ink-2); }
