/* Sistema de diseño compartido (tienda + panel).
   Referencia: "Limón" — brasserie a media luz. Un negro-olivo, un verde bosque, un amarillo limón
   y un crema cálido. Tracking ancho, esquinas de 1px, todo plano: sin sombras ni degradados. */
:root {
  --olive: #1d0b0d;
  --forest: #103b15;
  --lemon: #f7ea48;
  --cream: #fcf9f0;
  --sage: #dbe2dc;
  --white: #ffffff;
  --red: #a4161a; /* solo errores y acciones destructivas */

  --font: 'Outfit', 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius: 1px;
  --radius-round: 40px;
  --page: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
}

/* Contextos de color: cada sección declara si es clara u oscura y los componentes se adaptan. */
.light, :root {
  --bg: var(--cream);
  --fg: var(--olive);
  --fg-accent: var(--forest);
  --fg-muted: #46604a;
  --line: var(--sage);
  --line-strong: var(--forest);
  --field-bg: var(--white);
  --field-line: var(--forest);
  --out-bg: var(--olive);
  --out-fg: var(--cream);
  --ok-line: var(--sage);
  --ok-fg: var(--forest);
  --info-bg: var(--sage);
  --info-fg: var(--forest);
  --seg-bg: var(--forest);
  --seg-fg: var(--cream);
}
.dark {
  --bg: var(--olive);
  --fg: var(--cream);
  --fg-accent: var(--lemon);
  --fg-muted: rgb(252 249 240 / 0.74);
  --line: rgb(252 249 240 / 0.2);
  --line-strong: rgb(252 249 240 / 0.6);
  --field-bg: rgb(252 249 240 / 0.07);
  --field-line: rgb(252 249 240 / 0.55);
  --out-bg: var(--cream);
  --out-fg: var(--olive);
  --ok-line: rgb(252 249 240 / 0.5);
  --ok-fg: var(--cream);
  --info-bg: rgb(252 249 240 / 0.16);
  --info-fg: var(--cream);
  --seg-bg: var(--cream);
  --seg-fg: var(--olive);
}
.forest {
  --bg: var(--forest);
  --fg: var(--cream);
  --fg-accent: var(--lemon);
  --fg-muted: rgb(252 249 240 / 0.78);
  --line: rgb(252 249 240 / 0.24);
  --line-strong: rgb(252 249 240 / 0.6);
  --field-bg: rgb(252 249 240 / 0.08);
  --field-line: rgb(252 249 240 / 0.55);
  --out-bg: var(--cream);
  --out-fg: var(--olive);
  --ok-line: rgb(252 249 240 / 0.5);
  --ok-fg: var(--cream);
  --info-bg: rgb(252 249 240 / 0.16);
  --info-fg: var(--cream);
  --seg-bg: var(--lemon);
  --seg-fg: var(--forest);
}
.light, .dark, .forest { background: var(--bg); color: var(--fg); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 500; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Escala tipográfica del sistema */
.display-xl { font-size: clamp(46px, 8.2vw, 75px); line-height: 1; letter-spacing: 0.06em; font-weight: 400; text-transform: uppercase; }
.display    { font-size: clamp(40px, 7vw, 68px); line-height: 1.01; letter-spacing: 0.06em; font-weight: 400; text-transform: uppercase; }
.h-lg   { font-size: clamp(32px, 4.6vw, 46px); line-height: 1.1; letter-spacing: 0.04em; }
.h      { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.15; letter-spacing: 0.03em; }
.h-sm   { font-size: 30px; line-height: 1.15; letter-spacing: 0.03em; }
.sub    { font-size: 26px; line-height: 1.2; letter-spacing: 0.02em; }
.body-lg { font-size: 20px; line-height: 1.3; letter-spacing: 0.02em; }
.caption { font-size: 14px; line-height: 1.45; letter-spacing: 0.06em; }
.upper  { text-transform: uppercase; }
.muted  { color: var(--fg-muted); }
.accent { color: var(--fg-accent); }
.num    { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 12px; top: -64px; z-index: 300; padding: 10px 16px; background: var(--lemon); color: var(--olive); text-decoration: none; }
.skip:focus { top: 12px; }

/* ── Botones ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 12px 20px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap; background: none;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, opacity 0.18s;
}
.btn svg { flex: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Lemon: solo sobre fondos oscuros. */
.btn-lemon { background: var(--lemon); color: var(--olive); }
.btn-lemon:hover:not(:disabled) { background: var(--white); }
/* Sobre crema el CTA principal es negro-olivo. */
.btn-solid { background: var(--olive); color: var(--cream); }
.btn-solid:hover:not(:disabled) { background: var(--forest); }
.btn-outline { border-color: currentColor; color: inherit; }
.btn-outline:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
.btn-text { padding-inline: 8px; color: inherit; }
.btn-text:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }
.btn-danger { background: var(--red); color: var(--cream); }
.btn-danger:hover:not(:disabled) { background: #7d1013; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }

/* "ORDER NOW →": enlace fantasma con flecha */
.link-arrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0;
  font-size: 16px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-accent); text-decoration: none;
}
.link-arrow:hover { text-decoration: underline; text-underline-offset: 5px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  background: none; border: 0; border-radius: var(--radius); color: inherit;
}
.icon-btn:hover { background: rgb(128 128 128 / 0.18); }
.icon-btn.sm { width: 36px; height: 36px; }

/* ── Formularios ───────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .label {
  font-size: 14px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted);
}
.field small { color: var(--fg-muted); font-size: 14px; letter-spacing: 0.02em; }

input[type='text'], input[type='email'], input[type='tel'], input[type='number'],
input[type='password'], input[type='search'], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--field-bg); color: var(--fg);
  border: 1px solid var(--field-line); border-radius: var(--radius);
  transition: border-color 0.15s, background-color 0.15s;
}
select { appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m1 1 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
select option { background: var(--bg); color: var(--fg); }
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--fg-muted); opacity: 0.8; }
input:hover, select:hover, textarea:hover { border-color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fg-accent); outline-offset: 1px; border-color: var(--fg); }
input[type='color'] { width: 56px; height: 44px; padding: 3px; border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--field-bg); }
input[type='checkbox'], input[type='radio'] { width: 18px; height: 18px; accent-color: var(--fg-accent); flex: none; }
.err-text { color: #ff9a9a; font-weight: 500; letter-spacing: 0.02em; }
.light .err-text { color: var(--red); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.stepper button { width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; }
.stepper button:hover:not(:disabled) { background: rgb(128 128 128 / 0.2); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper output { min-width: 32px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Etiquetas de estado ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  background: transparent; color: inherit;
}
.badge.low   { background: var(--lemon); border-color: var(--olive); color: var(--olive); }
.badge.out   { background: var(--out-bg); border-color: var(--out-bg); color: var(--out-fg); }
.badge.ok    { border-color: var(--ok-line); color: var(--ok-fg); }
.badge.info  { background: var(--info-bg); border-color: transparent; color: var(--info-fg); }
.badge.danger { border-color: var(--red); color: var(--red); }

/* ── Diálogos ──────────────────────────────────────────── */
dialog {
  padding: 0; border: 1px solid var(--line); border-radius: 0;
  background: var(--bg); color: var(--fg);
  max-height: calc(100dvh - 24px); max-width: calc(100vw - 24px);
}
dialog::backdrop { background: rgb(10 4 5 / 0.72); }
dialog[open] { animation: fade-in 0.2s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Avisos ────────────────────────────────────────────── */
.toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 1000; width: min(92vw, 460px); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px;
  background: var(--olive); color: var(--cream); border: 1px solid var(--lemon); border-radius: var(--radius);
  font-size: 15px; animation: fade-in 0.2s ease-out;
}
.toast svg { flex: none; margin-top: 2px; color: var(--lemon); }
.toast.error { background: var(--red); border-color: var(--red); }
.toast.error svg { color: var(--cream); }

/* ── Selector de diseño (Limón / Shop) ─────────────────── */
.shop-only { display: none; }
.theme-switch {
  position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: #1d0b0d; color: #fcf9f0; border: 1px solid rgb(252 249 240 / 0.55); border-radius: var(--radius);
}
.theme-switch .ts-label { padding: 0 10px 0 8px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
.theme-switch button {
  min-height: 32px; padding: 0 12px; background: none; border: 0; border-radius: var(--radius); color: inherit;
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.theme-switch button:hover { background: rgb(128 128 128 / 0.25); }
.theme-switch button.is-active { background: #f7ea48; color: #1d0b0d; }
.admin-page .theme-switch { left: auto; right: 16px; }
@media (max-width: 560px) { .theme-switch .ts-label { display: none; } .theme-switch { left: 10px; bottom: 10px; } .admin-page .theme-switch { right: 10px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
