/* ==========================================================================
   BASE — variables de diseño, tipografía, botones, formularios y utilidades.
   Los colores principales se pueden cambiar en Administración > Ajustes > Marca
   (se inyectan como variables y sustituyen a los valores de :root).
   ========================================================================== */

@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/jost-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/jost-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113;
}
@font-face {
  font-family: 'Bodoni Moda';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/bodoni-moda-latin-opsz-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: 'Bodoni Moda';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/bodoni-moda-latin-ext-opsz-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113;
}
@font-face {
  font-family: 'Bodoni Moda';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/bodoni-moda-latin-opsz-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212;
}

:root {
  /* Paleta */
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --ink: #191919;
  --muted: #737373;
  --line: #E6E3DE;
  --accent: #8A7765;
  --dark: #20201E;
  --on-dark: #FFFFFF;
  --error: #9B2C1F;
  --error-bg: #F8ECE9;
  --success: #2B6447;
  --success-bg: #EAF2EC;
  --warn-bg: #F3EEE3;

  /* Derivados: texto secundario con contraste suficiente y acento apto para texto */
  --muted-text: #666461;
  --accent-text: #6E5E4F;
  --line-strong: #CFCAC2;

  /* Tipografía */
  --font-display: 'Bodoni Moda', 'Didot', 'Bodoni MT', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-ui: 'Jost', 'Futura', 'Century Gothic', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-base: 0.9375rem;
  --t-md: 1.0625rem;
  --t-lg: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --t-xl: clamp(1.75rem, 1.35rem + 1.7vw, 2.75rem);
  --t-2xl: clamp(2.25rem, 1.5rem + 3.4vw, 4.5rem);
  --t-hero: clamp(3rem, 1.2rem + 8vw, 8.5rem);

  /* Espaciado */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;
  --gutter: clamp(16px, 4vw, 56px);
  --max: 1680px;
  --header-h: 64px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fast: 160ms;
  --mid: 280ms;
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --muted-text: color-mix(in srgb, var(--muted) 82%, var(--ink));
    --accent-text: color-mix(in srgb, var(--accent) 78%, #000);
    --line-strong: color-mix(in srgb, var(--line) 82%, var(--ink));
  }
}

/* --- Reinicio ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
[hidden] { display: none !important; }
s { text-decoration-thickness: 1px; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
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-4); top: -100px; z-index: 200;
  background: var(--ink); color: var(--on-dark); padding: var(--s-3) var(--s-4);
}
.skip-link:focus { top: var(--s-3); }
.icon { flex: none; }

/* --- Tipografía ------------------------------------------------------------ */
.page-title, .section__title, .hero__title, .promo__title, .editorial__name, .product__name, .summary-title, .modal__title, .drawer__empty-title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.012em;
  line-height: 1.04;
  font-optical-sizing: auto;
}
.page-title { font-size: var(--t-2xl); }
.page-lead { color: var(--muted-text); font-size: var(--t-md); max-width: 60ch; margin-top: var(--s-3); }
.section__title { font-size: var(--t-xl); }
.section__lead { color: var(--muted-text); margin-top: var(--s-2); max-width: 56ch; }

.link {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
  transition: text-decoration-color var(--fast);
}
.link:hover { text-decoration-color: transparent; }
button.link { display: inline-flex; align-items: center; gap: 6px; }

.prose { max-width: 72ch; }
.prose > * + * { margin-top: var(--s-4); }
.prose h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-lg); margin-top: var(--s-7); line-height: 1.15; }
.prose h3 { font-size: var(--t-md); font-weight: 500; margin-top: var(--s-5); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: var(--s-2); }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose table { margin-top: var(--s-4); font-size: var(--t-sm); }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 500; background: var(--surface); }

/* --- Botones -------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 0 var(--s-6);
  font-size: var(--t-sm); font-weight: 500; letter-spacing: 0.05em; line-height: 1.2; text-align: center;
  border: 1px solid transparent; border-radius: 0; cursor: pointer;
  transition: background-color var(--fast), color var(--fast), border-color var(--fast), opacity var(--fast);
}
.btn--primary { background: var(--ink); color: var(--on-dark); border-color: var(--ink); }
.btn--primary:hover { background: transparent; color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--on-dark); }
.btn--light { background: var(--on-dark); color: var(--ink); border-color: var(--on-dark); }
.btn--light:hover { background: transparent; color: var(--on-dark); }
.btn--danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn--danger:hover { background: var(--error); color: #fff; }
.btn:active { opacity: 0.8; }
.btn--block { width: 100%; }
.btn--small { min-height: 40px; padding: 0 var(--s-4); }
.btn--large { min-height: 56px; font-size: var(--t-base); }
.btn[disabled], .btn.is-disabled { background: var(--line); border-color: var(--line); color: var(--muted-text); cursor: not-allowed; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-dark); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn--ghost.is-loading::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; color: var(--ink); border-radius: 50%;
  transition: background-color var(--fast);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--on-dark); border-radius: 9px; font-size: 10.5px; font-weight: 500; line-height: 1;
}

/* --- Formularios -------------------------------------------------------------------- */
.form > * + * { margin-top: var(--s-5); }
.form-grid { display: grid; gap: var(--s-4) var(--s-4); grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field--wide { grid-column: 1 / -1; }
}
.form-actions { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }

.field label, .coupon label, .filter legend, .buybox__group legend { display: block; font-size: var(--t-sm); font-weight: 500; margin-bottom: 6px; }
.field__optional { color: var(--muted-text); font-weight: 400; }
.field__hint { color: var(--muted-text); font-size: var(--t-xs); margin-top: 6px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"], input[type="search"],
input[type="url"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 0;
  transition: border-color var(--fast), box-shadow var(--fast);
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
select {
  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='%23191919' stroke-width='1.3'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input[readonly] { background: transparent; color: var(--muted-text); }
input::placeholder, textarea::placeholder { color: #8f8c87; }
[aria-invalid="true"], .has-error input:not([type="checkbox"]):not([type="radio"]), .has-error textarea, .has-error select { border-color: var(--error); }
.field-error { color: var(--error); font-size: var(--t-sm); margin-top: 6px; }
.form-message { font-size: var(--t-sm); min-height: 1.4em; }
.form-message.is-error { color: var(--error); }
.form-message.is-success { color: var(--success); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--t-sm); cursor: pointer; line-height: 1.45; }
.check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }
.check a { text-decoration: underline; text-underline-offset: 3px; }
.check__count { margin-left: auto; color: var(--muted-text); font-size: var(--t-xs); padding-left: var(--s-3); }

/* --- Avisos y estados ---------------------------------------------------------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: var(--s-3) var(--s-4); background: var(--warn-bg); border-left: 2px solid var(--accent);
  font-size: var(--t-sm);
}
.notice > div, .notice > span { flex: 1; }
.notice ul { list-style: disc; padding-left: 1.2em; margin-top: 6px; }
.notice a { text-decoration: underline; }
.notice--error { background: var(--error-bg); border-left-color: var(--error); color: var(--error); display: block; }
.notice--demo { background: var(--surface); border: 1px dashed var(--line-strong); border-left: 2px solid var(--accent); }
.notice--muted { background: transparent; border-left-color: var(--line-strong); color: var(--muted-text); }
.notice + .notice { margin-top: var(--s-3); }

.flash-stack { max-width: var(--max); margin: 0 auto; padding: var(--s-4) var(--gutter) 0; display: grid; gap: var(--s-2); }
.flash { padding: var(--s-3) var(--s-4); font-size: var(--t-sm); border-left: 2px solid var(--ink); background: var(--surface); }
.flash--success { border-left-color: var(--success); background: var(--success-bg); color: var(--success); }
.flash--error { border-left-color: var(--error); background: var(--error-bg); color: var(--error); }

.pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 500; background: var(--line); color: var(--ink); white-space: nowrap;
}
.pill--pending, .pill--pay-pending { background: #F1E7CF; color: #5E4B14; }
.pill--processing { background: #DDE6EE; color: #1F4161; }
.pill--shipped { background: #E3E0F0; color: #3B3270; }
.pill--delivered, .pill--pay-paid { background: var(--success-bg); color: var(--success); }
.pill--cancelled, .pill--pay-failed { background: var(--error-bg); color: var(--error); }
.pill--pay-refunded { background: var(--line); color: var(--ink); }

.tag {
  position: absolute; left: 10px; top: 10px; z-index: 2; padding: 4px 9px;
  background: var(--surface); color: var(--ink); font-size: 11.5px; font-weight: 500; letter-spacing: 0.03em; line-height: 1.2;
}
.tag--sale { background: var(--ink); color: var(--on-dark); }
.tag--muted { background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--muted-text); }
.tag--inline { position: static; display: inline-block; margin-bottom: var(--s-3); border: 1px solid var(--line-strong); background: transparent; }

.loading { color: var(--muted-text); padding: var(--s-5) 0; }
.empty-state { text-align: center; max-width: 560px; margin: 0 auto; padding: var(--s-9) 0; display: grid; gap: var(--s-4); justify-items: center; }
.empty-state h1, .empty-state h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-xl); line-height: 1.08; }
.empty-state p { color: var(--muted-text); }
.empty-state .btn { margin: var(--s-2) var(--s-1) 0; }
.error-code { font-family: var(--font-display); font-size: var(--t-hero); line-height: 0.9; color: var(--accent); }
.error-detail { text-align: left; font-size: 12px; overflow: auto; max-width: 100%; background: var(--surface); padding: var(--s-4); }

/* --- Tablas ------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { font-size: var(--t-sm); }
.table th { text-align: left; font-weight: 500; color: var(--muted-text); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .table thead { position: absolute; left: -9999px; }
  .table tr { display: block; padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
  .table td { display: flex; justify-content: space-between; gap: var(--s-4); padding: 4px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted-text); text-align: left; }
}

/* --- Totales ------------------------------------------------------------------------- */
.totals { display: grid; gap: var(--s-2); font-size: var(--t-sm); }
.totals__row { display: flex; justify-content: space-between; gap: var(--s-4); }
.totals__row dd { text-align: right; font-variant-numeric: tabular-nums; }
.totals__row--muted { color: var(--muted-text); }
.totals__row--total { font-size: var(--t-md); font-weight: 500; padding-top: var(--s-3); margin-top: var(--s-2); border-top: 1px solid var(--line-strong); }
.totals__note { color: var(--muted-text); font-size: var(--t-xs); margin-top: var(--s-3); }

.price { font-variant-numeric: tabular-nums; }
.price--sale { color: var(--accent-text); font-weight: 500; }
.price--old { color: var(--muted-text); margin-left: 6px; }

/* --- Movimiento reducido ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* El buscador tiene su propio botón de cierre: se oculta el control nativo de borrado. */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.field label.check { display: flex; font-weight: 400; margin-bottom: 0; }
