:root {
    --ink: #14213d;
    --muted: #5b6478;
    --line: #e2e8f0;
    --bg: #f8fafc;
    --surface: #ffffff;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --primary-hover: #1d4ed8;
    --border: #cbd5e1;
    --text-soft: #334155;
    --whatsapp: #128c4a;
    --danger: #b42318;
    --danger-soft: #fef0ee;
    --success: #14713f;
    --success-soft: #e8f6ee;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: var(--primary-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Encabezado */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { height: 44px; width: auto; }
.search { display: flex; flex: 1; min-width: 200px; gap: 8px; }
.search input { flex: 1; min-width: 0; }
.cart-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 8px 4px; }
.cart-badge { background: var(--primary); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.category-nav { border-top: 1px solid var(--line); }
.category-row { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; padding-bottom: 8px; }
.category-row a { white-space: nowrap; padding: 6px 14px; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .95rem; }
.category-row a:hover { background: var(--bg); }
.category-row a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

/* Formularios */
input[type="text"], input[type="search"], input[type="tel"], input[type="email"], input[type="number"], select, textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .35);
    outline-offset: 2px;
}
input[type="file"] { font: inherit; max-width: 100%; }
label, legend { font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field { margin-bottom: 16px; }
.field > label, .field > legend { display: block; margin-bottom: 6px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field-inline { display: flex; align-items: center; gap: 12px; }
.field-inline label { margin: 0; }
.field-inline input { width: 110px; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 10px; }

/* Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; border-radius: 10px; padding: 10px 18px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary, .search button { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover, .search button:hover { background: var(--bg); }
.search button { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; cursor: pointer; border-width: 1px; border-style: solid; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; font-size: 1.1rem; padding: 14px 26px; }
.btn-whatsapp:hover { filter: brightness(.93); }
.btn-block { width: 100%; margin-top: 10px; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn.disabled { opacity: .45; pointer-events: none; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary-dark); text-decoration: underline; cursor: pointer; }

/* Avisos */
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* Portada y catálogo */
.hero { background: linear-gradient(120deg, #1d4ed8, #2563eb 55%, #0891b2); color: #fff; border-radius: var(--radius); padding: 36px 28px; margin-bottom: 28px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); max-width: 18ch; }
.hero p { margin: 12px 0 0; max-width: 52ch; font-size: 1.05rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.product-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.product-thumb { position: relative; aspect-ratio: 1; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; }
.product-thumb img, .gallery-main img, .cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 3rem; font-weight: 800; color: var(--primary); opacity: .55; text-transform: uppercase; }
.tag { position: absolute; top: 10px; left: 10px; background: #0b1220; color: #fff; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.product-info { padding: 12px 14px 16px; }
.product-info h3 { font-size: 1rem; font-weight: 600; }
.price { font-weight: 700; margin: 6px 0 0; }
.price-lg { font-size: 1.6rem; color: var(--primary-dark); margin: 8px 0 14px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; }
.empty { text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 48px 16px; }

/* Ficha de producto */
.breadcrumb { display: flex; gap: 8px; font-size: .9rem; color: var(--muted); margin-bottom: 16px; }
.product-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.gallery-main { aspect-ratio: 1; background: var(--primary-soft); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs button { width: 68px; height: 68px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: none; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.description { color: var(--text-soft); margin: 0 0 18px; }
.variant-options, .choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.choice-row { margin-bottom: 16px; }
.variant-option { position: relative; cursor: pointer; font-weight: 500; }
.variant-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.variant-option span { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; background: var(--surface); }
.variant-option small { color: var(--muted); }
.variant-option input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.variant-option input:focus-visible + span { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }
.customization { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; }
.customization textarea { margin-bottom: 4px; }
.customization-preview { max-height: 180px; border-radius: 10px; margin: 12px 0; border: 1px solid var(--line); }
.customization label { display: block; margin-top: 4px; }

/* Carrito y checkout */
.cart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.card, .summary, .cart-line { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card { padding: 20px; margin-bottom: 16px; }
.card legend { float: left; width: 100%; font-size: 1.1rem; margin-bottom: 14px; padding: 0; }
.card legend + * { clear: both; }
.cart-line { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 16px; padding: 14px; margin-bottom: 12px; }
.cart-thumb { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; text-decoration: none; }
.cart-line-body h2 { font-size: 1.05rem; }
.cart-line-body h2 a { color: inherit; text-decoration: none; }
.cart-line-body p { margin: 2px 0; }
.cart-custom { display: flex; gap: 10px; align-items: center; background: var(--bg); border-radius: 10px; padding: 8px; margin: 8px 0; font-size: .9rem; }
.cart-custom img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.cart-custom p { margin: 0; overflow-wrap: anywhere; }
.cart-line-actions { display: flex; align-items: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.qty-form { display: flex; gap: 8px; }
.qty-form input { width: 84px; padding: 6px 10px; }
.cart-line-total { font-weight: 700; margin: 0; white-space: nowrap; }
.summary { padding: 20px; position: sticky; top: 130px; }
.summary h2 { margin-bottom: 14px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.summary-row > span:last-child, .summary-row > strong { white-space: nowrap; }
.summary-total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-size: 1.1rem; }

/* Confirmación */
.confirmation { text-align: center; padding: 28px 0 24px; }
.confirmation p { margin: 10px auto; max-width: 48ch; }
.confirmation .btn { margin-top: 12px; }
.order-summary { max-width: 620px; margin: 0 auto 24px; }
.order-summary h2 { margin-bottom: 12px; }
.order-meta { margin: 16px 0 0; display: grid; gap: 8px; }
.order-meta div { display: flex; gap: 12px; }
.order-meta dt { color: var(--muted); min-width: 90px; }
.order-meta dd { margin: 0; overflow-wrap: anywhere; }

/* Pie */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 20px 0; font-size: .95rem; color: var(--muted); }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.whatsapp-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--whatsapp); color: #fff; font-weight: 600; text-decoration: none; border-radius: 999px; padding: 9px 18px 9px 14px; box-shadow: 0 2px 8px rgba(18, 140, 74, .28); transition: transform .15s, box-shadow .15s, filter .15s; }
.whatsapp-pill:hover { filter: brightness(.94); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(18, 140, 74, .34); }
.whatsapp-pill svg { flex: none; }

@media (max-width: 860px) {
    .product-detail, .cart-layout { grid-template-columns: minmax(0, 1fr); }
    .summary { position: static; }
}

@media (max-width: 560px) {
    .brand { flex: 1; }
    .brand img { height: 30px; }
    .search { order: 3; flex: 1 1 200px; }
    .theme-toggle { order: 4; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .field-grid { grid-template-columns: minmax(0, 1fr); }
    .cart-line { grid-template-columns: 72px minmax(0, 1fr); }
    .cart-thumb { width: 72px; height: 72px; }
    .cart-line-total { grid-column: 2; }
    .hero { padding: 26px 20px; }
}

/* Seguimiento de pedido */
.header-link { font-weight: 600; color: var(--ink); text-decoration: none; padding: 8px 4px; white-space: nowrap; }
.header-link:hover, .cart-link:hover { color: var(--primary-dark); }
.tracking-lookup { max-width: 460px; margin: 0 auto; }
.tracking-lookup h1 { margin-bottom: 6px; }
.tracking-lookup .card { margin-top: 18px; }
.tracking { list-style: none; margin: 4px 0 18px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tracking li { position: relative; text-align: center; font-size: .85rem; color: var(--muted); padding-top: 30px; }
.tracking li::before { content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 3px; background: var(--line); }
.tracking li:first-child::before { display: none; }
.tracking-dot { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 19px; height: 19px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line); z-index: 1; }
.tracking li.done::before, .tracking li.current::before { background: var(--primary); }
.tracking li.done .tracking-dot { background: var(--primary); border-color: var(--primary); }
.tracking li.current .tracking-dot { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.tracking li.done, .tracking li.current { color: var(--ink); }
.tracking li.current .tracking-label { font-weight: 700; }
.status-description { margin: 0; font-weight: 500; }
.status-badge { display: inline-block; border-radius: 999px; padding: 4px 14px; font-weight: 700; margin: 0 0 12px; }
.status-cancelled { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 560px) {
    .tracking { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .tracking li { text-align: left; padding: 0 0 18px 34px; font-size: .95rem; }
    .tracking li:last-child { padding-bottom: 0; }
    .tracking li::before { top: -21px; left: 8px; width: 3px; height: 23px; }
    .tracking-dot { top: 1px; left: 0; transform: none; }
}

/* Mantenimiento */
.maintenance-page { background: var(--surface); justify-content: center; align-items: center; }
.maintenance { text-align: center; padding: 32px 20px; max-width: 520px; }
.maintenance img { width: min(300px, 70vw); height: auto; margin: 0 auto 8px; }
.maintenance p { color: var(--muted); font-size: 1.05rem; margin: 12px 0 24px; }
.maintenance-banner { background: #fef3c7; color: #78350f; text-align: center; font-size: .92rem; font-weight: 600; padding: 8px 16px; }
.maintenance-banner a { color: inherit; }

/* Campo trampa contra bots: fuera de pantalla, invisible para personas */
.hp-field { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Tema oscuro: se activa con el botón del encabezado y se recuerda en el navegador */
[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e6ebf5;
    --muted: #9aa7bd;
    --line: #2a3650;
    --bg: #0d1526;
    --surface: #172036;
    --primary: #3b82f6;
    --primary-dark: #93c5fd;
    --primary-soft: #1e3357;
    --primary-hover: #2563eb;
    --border: #3a4866;
    --text-soft: #c3cde0;
    --danger: #ffb4a8;
    --danger-soft: #4a1f1b;
    --success: #8fe0b0;
    --success-soft: #153d2a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .thumb-placeholder { color: #93c5fd; }
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: #7f8ba3; }

.brand .logo-dark { display: none; }
[data-theme="dark"] .brand .logo-light { display: none; }
[data-theme="dark"] .brand .logo-dark { display: block; }

.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--bg); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
