/* Pedí Acá — tienda pública. Pensada primero para celular. */
:root {
    --bg: #fff8f1;
    --surface: #ffffff;
    --ink: #2a1f19;
    --muted: #7a6a60;
    --line: #f0e2d6;
    --accent: #1b4d2e;
    --accent-dark: #133a22;
    --open: #15803d;
    --closed: #9b8b80;
    --wa: #1f9d55;
    --wa-dark: #187d43;
    --danger: #b91c1c;
    --radius: 14px;
    --bar-h: 68px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* Encabezado */
.topbar { background: var(--accent) url("../img/motos.svg") 0 0 / 420px 280px repeat; color: #fff; padding: 14px 16px 12px; }
.topbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-link {
    flex-shrink: 0; margin-top: 4px; padding: 5px 10px; border: 1px solid rgba(255,255,255,.55); border-radius: 999px;
    color: #fff; font-size: .8rem; text-decoration: none; opacity: .9;
}
.admin-link:hover, .admin-link:focus-visible { background: rgba(255,255,255,.15); opacity: 1; }
.brand { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.brand a { color: inherit; text-decoration: none; }
.brand a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tagline { margin: 2px 0 0; font-size: .9rem; opacity: .92; }

/* Solapas de comercios, como un fichero: la elegida queda abierta hacia la hoja de abajo */
.tabs {
    --tab-line: #cdbcae;
    position: sticky; top: 0; z-index: 20;
    display: flex; gap: 4px; align-items: flex-end; overflow-x: auto; scrollbar-width: none;
    padding: 12px 16px 0;
    /* La línea del fichero se dibuja como fondo para que la solapa elegida pueda taparla. */
    background: linear-gradient(to top, var(--tab-line) 2px, var(--bg) 2px);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto; min-width: 128px; max-width: 200px; margin-top: 6px;
    display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
    padding: 12px 12px 8px; border-radius: 12px 12px 0 0; text-align: left;
    background: #f1e7de; border: 2px solid var(--tab-line);
    position: relative; overflow: hidden;
}
.tab::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--truck-stripe, var(--truck)); }
.tab:hover { background: #f7f0ea; }
.tab[aria-selected="true"] {
    margin-top: 0; padding-bottom: 14px; z-index: 1;
    background: var(--sheet-top, var(--bg)); border-bottom-color: var(--sheet-top, var(--bg));
    box-shadow: 0 -4px 10px rgb(0 0 0 / .07);
}

/* Hoja del comercio elegido: su paleta lavada y en degradado, para saber siempre dónde estás */
.sheet { background: var(--sheet, var(--bg)); min-height: calc(100vh - 140px); }
.sheet-closed .sheet { background: #efebe7; }

/* Carrusel: la paleta del comercio nuevo gana terreno de costado, con el borde difuminado */
.sheet { position: relative; }
.sheet > .layout { position: relative; } /* sin z-index: así la hoja del pedido (celular) queda encima de todo */
.sheet-wipe {
    position: absolute; inset: 0; pointer-events: none;
    -webkit-mask-size: 300% 100%; mask-size: 300% 100%;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    animation: .52s cubic-bezier(.22,.7,.25,1) both;
}
.sheet-wipe.from-right {
    -webkit-mask-image: linear-gradient(to left, #000 40%, transparent 60%); mask-image: linear-gradient(to left, #000 40%, transparent 60%);
    animation-name: wipe-from-right;
}
.sheet-wipe.from-left {
    -webkit-mask-image: linear-gradient(to right, #000 40%, transparent 60%); mask-image: linear-gradient(to right, #000 40%, transparent 60%);
    animation-name: wipe-from-left;
}
@keyframes wipe-from-right { from { -webkit-mask-position: 0 0; mask-position: 0 0; } to { -webkit-mask-position: 100% 0; mask-position: 100% 0; } }
@keyframes wipe-from-left { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }

/* Mientras se desliza, el comercio que sale queda en el mismo lugar, por debajo del que entra */
.menu { position: relative; overflow-x: clip; }
.panel { position: relative; z-index: 1; }
.panel-leaving { position: absolute; z-index: 0; left: 0; right: 0; pointer-events: none; }
.sheet-closed .tab[aria-selected="true"] { background: #efebe7; border-bottom-color: #efebe7; }

/* Comercio cerrado: en gris y con el cartel "No disponible" encima */
.closed-sign { display: none; }
.is-closed .closed-sign {
    display: block; position: absolute; z-index: 2; left: 50%; top: 50%;
    transform: translate(-50%, -50%) rotate(-6deg);
    padding: 2px 8px; border: 2px solid #3f3f46; border-radius: 6px;
    background: rgb(255 255 255 / .92); color: #3f3f46; text-shadow: none;
    font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.tab.is-closed { filter: grayscale(1); }
.tab.is-closed:not([aria-selected="true"]) { opacity: .75; }
.tab.is-closed .tab-name, .tab.is-closed .tab-meta { opacity: .45; }
.panel.is-closed { filter: grayscale(1); }
.panel.is-closed .closed-sign { font-size: 1.15rem; padding: 6px 18px; border-width: 3px; }
.tab-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab-meta { display: flex; gap: 6px; align-items: center; }
.status { font-size: .75rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; }
.status.is-open { background: #dcfce7; color: var(--open); }
.status.is-closed { background: #efe9e4; color: var(--closed); }
.tab-count {
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
    background: var(--truck); color: #fff; font-size: .78rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

/* Diseño general */
.layout { max-width: 1200px; margin: 0 auto; padding: 0 16px calc(var(--bar-h) + 24px + env(safe-area-inset-bottom)); }
.menu { min-width: 0; }
.empty-store { max-width: 600px; margin: 40px auto; padding: 0 16px; text-align: center; color: var(--muted); }

/* Menú de un comercio: encabezado con el degradado de su paleta */
.truck-head {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: flex-end;
    position: relative; margin: 16px 0 10px; padding: 26px 18px 16px; border-radius: var(--radius);
    background: var(--truck-gradient, var(--truck)); color: #fff;
    text-shadow: 0 1px 3px rgb(0 0 0 / .35); box-shadow: 0 4px 14px rgb(0 0 0 / .12);
}
.truck-head h2 { margin: 0; font-size: 1.5rem; }
.truck-category { margin: 2px 0 0; opacity: .95; }
.truck-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .88rem; }
.closed-note { background: #f5ede7; border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: .92rem; }
.section-title { margin: 20px 0 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.products { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; align-items: start; }
.product {
    display: flex; gap: 12px; justify-content: space-between; align-items: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.product-info { min-width: 0; }
.product h4 { margin: 0; font-size: 1rem; }
.product p { margin: 3px 0 0; font-size: .88rem; color: var(--muted); }
.price { display: inline-block; margin-top: 6px; font-weight: 700; }
/* Producto sin stock: en gris, con el cartel en diagonal (igual que un comercio cerrado) */
.product { position: relative; }
.product.is-out-of-stock { filter: grayscale(1); }
.product.is-out-of-stock > :not(.stock-sign) { opacity: .5; }
.product.is-out-of-stock .unavailable { display: none; } /* ya lo dice el cartel */
.stock-sign {
    position: absolute; z-index: 2; left: 50%; top: 50%;
    transform: translate(-50%, -50%) rotate(-8deg);
    padding: 5px 16px; border: 3px solid #3f3f46; border-radius: 8px;
    background: rgb(255 255 255 / .92); color: #3f3f46;
    font-size: 1rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
    pointer-events: none;
}

.unavailable { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.product-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; }
.product-action { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Producto con foto: la foto va a la derecha y el botón «Agregar» se apoya sobre su borde de abajo */
.product.has-image { align-items: flex-start; }
.product.has-image .product-side { width: 168px; align-items: center; }
.product-photo {
    width: 100%; aspect-ratio: 4 / 3; border-radius: 12px;
    background: #efe6de center / cover no-repeat; box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.product.has-image .product-action { flex-direction: column-reverse; align-items: center; margin-top: -19px; }
.product.has-image .btn-add, .product.has-image .stepper { box-shadow: 0 2px 8px rgb(0 0 0 / .18); }
.product.has-image .unavailable { background: #fff; padding: 4px 10px; border-radius: 99px; }
@media (max-width: 520px) {
    .product.has-image .product-side { width: 124px; }
    .product.has-image .btn-add { padding: 6px 12px; }
}
.product { flex-wrap: wrap; }
.product-info { flex: 1 1 0; }
.ingredients-hint { display: block; margin-top: 4px; font-size: .8rem; font-weight: 600; color: var(--truck); }
.in-cart { font-size: .78rem; font-weight: 700; color: var(--truck); white-space: nowrap; }

/* Menú desplegable de ingredientes: vienen todos tildados; destildar = sacar */
.ingredients-menu {
    flex: 1 1 100%; margin-top: 2px; padding: 12px; border-radius: 12px;
    background: #fbf6f2; border: 1px dashed var(--truck);
}
.product .ingredients-title { margin: 0 0 8px; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ingredients-title span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ingredients-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.ingredient-option {
    display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center;
    padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: .93rem;
    background: color-mix(in srgb, var(--truck) 8%, #fff); border: 1px solid var(--truck);
}
.ingredient-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--truck); }
.ingredient-removed { display: none; font-size: .75rem; font-weight: 800; color: var(--danger); text-transform: uppercase; }
.ingredient-option:has(input:not(:checked)) { background: #fff; border-color: var(--line); }
.ingredient-option:has(input:not(:checked)) .ingredient-name { text-decoration: line-through; color: var(--muted); }
.ingredient-option:has(input:not(:checked)) .ingredient-removed { display: inline; }

/* Opciones (sabor, marca...): se elige una sola */
.options-group { border: 0; margin: 0 0 10px; padding: 0; min-width: 0; }
.options-group legend { padding: 0; }
.options-list { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.option-pick {
    display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center;
    padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: .93rem;
    background: #fff; border: 1px solid var(--line);
}
.option-pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--truck); }
.option-pick:has(input:checked) { background: color-mix(in srgb, var(--truck) 8%, #fff); border-color: var(--truck); font-weight: 700; }
.option-pick.is-out { cursor: not-allowed; color: var(--muted); background: #f4f1ee; }
.option-pick.is-out span { text-decoration: line-through; }
.option-pick small { font-size: .7rem; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.btn-add-combo {
    width: 100%; border: 0; border-radius: 99px; padding: 10px 16px; font-weight: 800;
    background: var(--truck); color: #fff;
}
.btn-add-combo:hover { filter: brightness(1.08); }
.cart-without { display: block; color: var(--danger); font-size: .8rem; font-weight: 600; }
.btn-add {
    border: 2px solid var(--truck); background: #fff; color: var(--ink);
    border-radius: 99px; padding: 7px 16px; font-weight: 700;
}
.btn-add:hover { background: var(--truck); color: #fff; }
.btn-add:disabled { border-color: var(--line); color: var(--closed); background: #faf6f2; cursor: not-allowed; }

/* Selector de cantidad */
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--truck, var(--accent)); border-radius: 99px; overflow: hidden; background: #fff; }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; font-size: 1.2rem; font-weight: 700; line-height: 1; }
.stepper button:hover { background: #f6eee8; }
.stepper button:disabled { color: var(--closed); cursor: not-allowed; }
.stepper output { min-width: 26px; text-align: center; font-weight: 700; }
.stepper.small button { width: 28px; height: 28px; font-size: 1rem; }

/* Comanda (carrito + datos) */
.comanda { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.comanda-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.comanda-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-close { border: 0; background: #f4ece6; width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; }
.comanda-body { padding: 4px 16px 18px; }
.cart-empty { color: var(--muted); font-size: .92rem; }
.cart-group { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.cart-truck { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .98rem; }
.cart-truck::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--truck-gradient, var(--truck)); }
.cart-line { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: .93rem; }
.cart-line-total { font-weight: 600; white-space: nowrap; }
.cart-subtotal { display: flex; justify-content: space-between; color: var(--muted); font-size: .88rem; margin-top: 6px; }
.cart-warning { margin: 6px 0 0; color: var(--danger); font-size: .85rem; }
.cart-notice { background: #ecf5ef; border-radius: 10px; padding: 8px 10px; font-size: .85rem; color: var(--accent-dark); }

.checkout h3 { margin: 18px 0 8px; font-size: 1rem; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 4px; }
.field small, .choice small { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid #e2d3c7; border-radius: 10px; background: #fff;
    font-size: 16px; /* evita el zoom automático en iPhone */
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(27 77 46 / .18); }
.field input.invalid { border-color: var(--danger); }
.choice { border: 0; padding: 0; margin: 4px 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice legend { font-size: .87rem; font-weight: 600; margin-bottom: 4px; padding: 0; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choice span {
    display: flex; flex-direction: column; justify-content: center; min-height: 48px; height: 100%;
    padding: 8px 10px; border: 1.5px solid #e2d3c7; border-radius: 10px; font-size: .9rem; font-weight: 600; text-align: center; background: #fff;
}
.choice input:checked + span { border-color: var(--accent); background: #e8f3ec; color: var(--accent-dark); }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgb(27 77 46 / .25); }
.hint { font-size: .85rem; color: var(--muted); margin: -4px 0 10px; }
.hint.center { text-align: center; margin: 8px 0 0; }
.hint.warn { color: var(--danger); }
.alias-box { background: #f6f0eb; border-radius: 10px; padding: 10px 12px; margin: 0 0 8px; font-size: .92rem; }
.btn-link { border: 0; background: none; color: var(--accent-dark); font-weight: 700; text-decoration: underline; padding: 0 0 0 6px; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 16px 0 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .93rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.form-errors { background: #fdecec; color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: .9rem; }
.form-errors ul { margin: 0; padding-left: 18px; }
.btn-send {
    display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; text-align: center; text-decoration: none;
    background: var(--wa); color: #fff; font-weight: 800; font-size: 1.05rem;
}
.btn-send:hover { background: var(--wa-dark); }
.btn-send:disabled { background: #a7c9b4; cursor: not-allowed; }

/* Barra fija del celular */
.mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgb(255 248 241 / .96);
    border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.mobile-bar-btn {
    width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 13px 16px; border: 0; border-radius: 12px; background: var(--wa); color: #fff; font-weight: 700; font-size: 1rem;
}
.mobile-bar-btn.is-empty { background: #b9ab9f; }
.bar-subtotal { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.bar-subtotal small { font-size: .72rem; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }

/* Hoja desde abajo (celular) */
@media (max-width: 899px) {
    .comanda {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
        border-radius: 18px 18px 0 0; border-bottom: 0;
        transform: translateY(105%); transition: transform .25s ease; visibility: hidden;
    }
    .comanda.open { transform: translateY(0); visibility: visible; }
    .comanda-body { overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
    .backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .4); }
    body.sheet-open { overflow: hidden; }
    body.sheet-open .mobile-bar { display: none; }
}

/* Escritorio: columna fija a la derecha */
@media (min-width: 900px) {
    .layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; padding-bottom: 40px; }
    .comanda { position: sticky; top: 92px; max-height: calc(100vh - 108px); display: flex; flex-direction: column; margin-top: 18px; }
    .comanda-body { overflow-y: auto; }
    .sheet-close, .mobile-bar, .backdrop { display: none !important; }
    .tabs { padding-left: max(16px, calc((100vw - 1200px) / 2 + 16px)); }
    .products { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* Pantalla de "pedido enviado" */
.sent { position: fixed; inset: 0; z-index: 80; background: rgb(0 0 0 / .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sent-box { background: #fff; border-radius: 16px; padding: 22px; max-width: 360px; width: 100%; text-align: center; }
.sent-title { font-size: 1.2rem; font-weight: 800; margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
    .comanda { transition: none; }
}

/* Portada: presenta el servicio sin favorecer a ningún comercio */
.tab-home { min-width: 96px; }
.tab-home::before { background: var(--accent); }
.tab-home-hint { font-size: .75rem; color: var(--muted); }
.landing { padding: 18px 0 8px; }
.landing-hero {
    padding: 26px 20px; border-radius: var(--radius); color: #fff;
    background: var(--accent) url("../img/motos.svg") 0 0 / 420px 280px repeat;
    box-shadow: 0 4px 14px rgb(0 0 0 / .12);
}
.landing-hero h2 { margin: 0 0 6px; font-size: 1.45rem; line-height: 1.2; letter-spacing: -.01em; }
.landing-hero p { margin: 0; opacity: .95; }
.landing-steps {
    list-style: none; margin: 16px 0 0; padding: 0; counter-reset: step;
    display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.landing-steps li {
    display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
    padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.step-icon { grid-row: span 2; font-size: 1.8rem; line-height: 1; }
.landing-steps strong { font-size: 1.05rem; }
.landing-steps span:last-child { color: var(--muted); font-size: .9rem; }
.landing-title { margin: 24px 0 10px; font-size: 1.1rem; }
.landing-trucks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.landing-truck {
    position: relative; overflow: hidden; width: 100%; min-height: 104px; text-align: left;
    display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
    padding: 14px; border: 0; border-radius: 14px; color: #fff;
    background: var(--truck-gradient, var(--truck)); text-shadow: 0 1px 3px rgb(0 0 0 / .35);
    box-shadow: 0 3px 10px rgb(0 0 0 / .12); transition: transform .15s ease, box-shadow .15s ease;
}
.landing-truck:hover, .landing-truck:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 16px rgb(0 0 0 / .16); }
.landing-truck-name { font-weight: 800; font-size: 1.1rem; }
.landing-truck-category { font-size: .9rem; opacity: .95; }
.landing-truck-status { font-size: .78rem; opacity: .9; margin-top: 4px; }
.landing-truck.is-closed { filter: grayscale(1); opacity: .7; }
