/* Mercado local (productos.php · /productos/{ofertas|novedades}).
   Usa los tokens y tarjetas .vv de vitrina-ds.css.

   Barra fija (sticky) bajo el navbar, estilo iOS (vidrio esmerilado + línea fina):
   - PC (≥1024px): una sola fila [Ofertas|Novedades] [búsqueda] [ciudad]; los filtros
     van en una barra lateral que también queda fija → filtrar nunca requiere volver arriba.
   - Móvil/tablet: fila 1 [búsqueda] [ciudad] [filtros] siempre visible; fila 2
     [Ofertas|Novedades] + categorías rápidas, que se esconde al bajar y vuelve al subir
     (como Safari en iOS). La fila 2 se superpone (no empuja el contenido) para no dar saltos.

   --mk-top (alto del navbar) y --mk-bar-h (alto de la fila 1) los mide vv-productos.js. */

.vv-mk {
    --mk-top: 70px;
    --mk-bar-h: 58px;
    --mk-row2-h: 50px;
    --mk-glass: rgba(243, 246, 245, .8);
    --mk-fill: rgba(118, 118, 128, .12);       /* relleno de controles iOS */
    --mk-hair: rgba(20, 32, 30, .1);           /* línea fina iOS */
    --mk-ease: cubic-bezier(.32, .72, 0, 1);
    min-height: 70vh; padding-bottom: 2.5rem;
    overflow-x: clip; /* el vidrio de la barra se extiende a todo el ancho sin crear scroll horizontal */
}

/* ── Encabezado ── */
.vv-mk-head { padding: .9rem 0 .7rem; }
.vv-mk-head h1 {
    font-family: 'Poppins', sans-serif; font-size: clamp(1.5rem, 1.15rem + 1.4vw, 2.1rem);
    margin: 0 0 .2rem; color: var(--vv-ink); letter-spacing: -0.025em; line-height: 1.1;
    display: flex; align-items: center; gap: .55rem;
}
.vv-mk-head h1 i { color: var(--vv-hot); font-size: .85em; }
.vv-mk-head p { margin: 0; color: var(--vv-muted); font-size: .92rem; }

/* ── Barra fija ── */
.vv-mk-toolbar { position: sticky; top: var(--mk-top); z-index: 50; }

/* Vidrio a todo el ancho de la ventana, en un pseudo-elemento: un backdrop-filter en el
   propio contenedor convertiría al menú de ciudad (position: fixed en móvil) en hijo de la barra. */
.vv-mk-row1::before,
.vv-mk-row2::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%);
    z-index: -1; pointer-events: none;
    background: var(--mk-glass);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.vv-mk-row1 {
    position: relative; z-index: 2;
    display: flex; align-items: center; gap: .6rem; padding: .6rem 0;
}
.vv-mk-row1::before { box-shadow: 0 .5px 0 var(--mk-hair); transition: box-shadow .2s ease; }

/* Fila 2: se superpone bajo la fila 1 y se desliza detrás de ella al compactar */
.vv-mk-row2 {
    display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 1;
    height: var(--mk-row2-h);
    transition: transform .3s var(--mk-ease), opacity .2s ease, visibility .3s;
}
.vv-mk-row2::before { box-shadow: 0 .5px 0 var(--mk-hair); }
.vv-mk-row2-scroll {
    height: 100%; display: flex; align-items: center; gap: .45rem;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    scroll-padding-inline: 1rem; overscroll-behavior-x: contain;
}
.vv-mk-row2-scroll::-webkit-scrollbar { display: none; }
.vv-mk-row2-space { display: none; height: var(--mk-row2-h); }
.vv-mk-toolbar.is-compact .vv-mk-row2 { transform: translateY(-100%); opacity: 0; visibility: hidden; pointer-events: none; }

/* Control segmentado (iOS) */
.vv-mk-seg {
    flex: none; display: inline-flex; padding: 2px; gap: 2px; border-radius: 10px; background: var(--mk-fill);
}
.vv-mk-tab {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap;
    padding: .38rem .85rem; border-radius: 8px; text-decoration: none;
    font-weight: 600; font-size: .84rem; color: var(--vv-ink);
    transition: background .2s ease, box-shadow .2s ease, color .2s ease;
}
.vv-mk-tab i { font-size: .8em; color: var(--vv-muted); }
.vv-mk-tab:hover { color: var(--vv-brand); }
.vv-mk-tab[aria-current="page"] { background: #fff; color: var(--vv-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.vv-mk-tab[aria-current="page"] i { color: var(--vv-hot); }
.vv-mk-tab:focus-visible { outline: 2px solid var(--vv-brand); outline-offset: 1px; }

/* Campo de búsqueda */
.vv-mk-search {
    flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: .55rem; cursor: text;
    padding: 0 .4rem 0 .95rem; border-radius: 999px; color: var(--vv-muted);
    background: #fff; border: 1px solid var(--vv-line);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.vv-mk-search:focus-within { border-color: var(--vv-brand); box-shadow: 0 0 0 4px rgba(14, 90, 85, .12); }
.vv-mk-search input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
    font: inherit; font-size: .95rem; color: var(--vv-ink);
}
.vv-mk-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.vv-mk-qclear {
    flex: none; width: 30px; height: 30px; border: 0; background: none; cursor: pointer; padding: 0;
    color: #a3adab; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.vv-mk-qclear:hover { color: var(--vv-muted); }
.vv-mk-qclear[hidden] { display: none; }

/* Ciudad dentro de la barra */
.vv-mk-toolbar .vv-loc { margin: 0; flex: none; }

/* Botón de filtros (móvil/tablet) */
.vv-mk-filter-btn {
    position: relative; flex: none; display: none; align-items: center; gap: .45rem; cursor: pointer;
    height: 42px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--vv-line); background: #fff;
    font: inherit; font-weight: 600; font-size: .9rem; color: var(--vv-ink);
}
.vv-mk-filter-btn i { color: var(--vv-brand); }
.vv-mk-badge {
    min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px;
    background: var(--vv-hot); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.vv-mk-badge[hidden] { display: none; }

/* Categorías rápidas (fila 2) */
.vv-mk-vsep { flex: none; width: 1px; height: 22px; background: var(--mk-hair); margin: 0 .15rem; }
.vv-mk-qcat {
    flex: none; display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; white-space: nowrap;
    height: 32px; padding: 0 .8rem; border-radius: 999px; border: 0;
    background: #fff; box-shadow: inset 0 0 0 1px var(--vv-line);
    font: inherit; font-size: .82rem; font-weight: 600; color: var(--vv-ink);
    transition: background .15s ease, color .15s ease;
}
.vv-mk-qcat i { font-size: .8rem; }
.vv-mk-qcat[aria-pressed="true"] { background: var(--vv-ink); color: #fff; box-shadow: none; }
.vv-mk-qcat[aria-pressed="true"] i { color: #fff !important; }
.vv-mk-qcat:focus-visible { outline: 2px solid var(--vv-brand); outline-offset: 2px; }

.vv-mk-locmsg { margin: .5rem 0 0; }

/* ── Distribución ── */
.vv-mk-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.vv-mk-main { min-width: 0; }

/* ── Filtros: barra lateral fija (PC) ── */
.vv-mk-aside {
    position: sticky; top: calc(var(--mk-top) + var(--mk-bar-h) + 1rem);
    max-height: calc(100vh - var(--mk-top) - var(--mk-bar-h) - 2rem);
    margin-top: 1rem; display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--vv-line); border-radius: var(--vv-radius);
}
.vv-mk-aside-head {
    display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem;
    border-bottom: 1px solid var(--vv-line);
}
.vv-mk-aside-head strong {
    order: -1; flex: 1; display: inline-flex; align-items: center; gap: .45rem; color: var(--vv-ink); font-size: .95rem;
}
.vv-mk-aside-head strong i { color: var(--vv-brand); }
.vv-mk-aside-body { overflow-y: auto; overscroll-behavior: contain; padding: .1rem 1rem 1rem; scrollbar-width: thin; }
.vv-mk-aside-foot, .vv-mk-done { display: none; }

.vv-mk-link {
    background: none; border: 0; padding: .2rem .1rem; cursor: pointer; font: inherit;
    font-size: .84rem; font-weight: 600; color: var(--vv-brand);
}
.vv-mk-link:hover { text-decoration: underline; }

.vv-mk-group { border: 0; margin: 0; padding: .85rem 0 0; min-width: 0; }
.vv-mk-group + .vv-mk-group { margin-top: .6rem; }
.vv-mk-group legend {
    padding: 0; margin-bottom: .45rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--vv-muted);
}

.vv-mk-cats { display: flex; flex-direction: column; gap: 1px; }
.vv-mk-cat {
    position: relative; display: flex; align-items: center; gap: .6rem; cursor: pointer;
    padding: .38rem .45rem; border-radius: 10px; transition: background .15s ease;
}
.vv-mk-cat:hover { background: var(--vv-sunken); }
.vv-mk-cat input { position: absolute; opacity: 0; pointer-events: none; }
.vv-mk-cat-ico {
    flex: none; width: 28px; height: 28px; border-radius: 8px; color: #fff; font-size: .76rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.vv-mk-cat-name { font-size: .87rem; color: var(--vv-ink); line-height: 1.2; }
.vv-mk-cat:has(input:checked) { background: var(--vv-hot-soft); }
.vv-mk-cat:has(input:checked) .vv-mk-cat-name { font-weight: 700; color: var(--vv-hot-dark); }
.vv-mk-cat:has(input:focus-visible) { outline: 2px solid var(--vv-brand); outline-offset: 1px; }

.vv-mk-price { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: .4rem; }
.vv-mk-price label { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.vv-mk-price label span { font-size: .74rem; color: var(--vv-muted); }
.vv-mk-price input {
    width: 100%; min-width: 0; padding: .55rem .65rem; font: inherit; font-size: .9rem; color: var(--vv-ink);
    border: 1px solid var(--vv-line); border-radius: 10px; background: #fff; outline: 0;
}
.vv-mk-price input:focus { border-color: var(--vv-brand); box-shadow: 0 0 0 3px rgba(14, 90, 85, .12); }
.vv-mk-price-sep { padding-bottom: .6rem; color: var(--vv-muted); }
.vv-mk-hint { margin: .45rem 0 0; font-size: .74rem; color: var(--vv-muted); line-height: 1.35; }

/* ── Resumen + chips de filtros activos ── */
.vv-mk-meta { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0 .9rem; }
.vv-mk-info { margin: 0; font-size: .86rem; color: var(--vv-muted); min-height: 1.2em; }
.vv-mk-info b { color: var(--vv-ink); }
.vv-mk-info-loc { color: var(--vv-brand); font-weight: 600; }
.vv-mk-note {
    display: block; margin-top: .45rem; padding: .55rem .8rem; border-radius: 10px;
    background: #fff8e6; border: 1px solid rgba(255, 176, 0, .35); color: var(--vv-ink);
}
.vv-mk-chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.vv-mk-chips:empty { display: none; }
.vv-mk-chip {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    padding: .32rem .7rem; border-radius: 999px; border: 0; box-shadow: inset 0 0 0 1px rgba(14, 90, 85, .25);
    background: #fff; font: inherit; font-size: .8rem; font-weight: 600; color: var(--vv-brand);
}
.vv-mk-chip:hover { background: var(--vv-sunken); }
.vv-mk-chip .fa-xmark { opacity: .7; }

/* ── Resultados ── */
.vv-mk-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); scroll-margin-top: calc(var(--mk-top) + var(--mk-bar-h) + 1rem); }

.vv-mk-sep {
    grid-column: 1 / -1; display: flex; align-items: center; gap: .85rem;
    margin: .6rem 0 .2rem; padding: .9rem 1.1rem; border-radius: var(--vv-radius);
    background: #fff; border: 1px dashed rgba(14, 90, 85, .35);
}
.vv-mk-sep-ico {
    flex: none; width: 40px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(14, 90, 85, .1); color: var(--vv-brand); font-size: 1.05rem;
}
.vv-mk-sep div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.vv-mk-sep strong { color: var(--vv-ink); font-size: .95rem; }
.vv-mk-sep span { color: var(--vv-muted); font-size: .82rem; }

.vv-mk-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 2.5rem 1rem; }
.vv-mk-empty i { font-size: 1.8rem; color: #c8cecd; margin-bottom: .3rem; }
.vv-mk-empty strong { color: var(--vv-ink); font-size: 1rem; }
.vv-mk-empty button {
    margin-top: .6rem; border: 0; cursor: pointer; padding: .55rem 1.2rem; border-radius: 999px;
    background: var(--vv-brand); color: #fff; font: inherit; font-weight: 600; font-size: .88rem;
}

.vv-mk-backdrop[hidden] { display: none; }

/* ════════════ Móvil / tablet ════════════ */
@media (max-width: 1023.98px) {
    .vv-mk-seg-desk { display: none; }
    .vv-mk-row2, .vv-mk-row2-space { display: block; }
    .vv-mk-filter-btn { display: inline-flex; }
    .vv-mk-layout { grid-template-columns: minmax(0, 1fr); }

    /* La línea de la fila 1 solo se ve cuando la fila 2 está escondida */
    .vv-mk-row1::before { box-shadow: none; }
    .vv-mk-toolbar.is-compact .vv-mk-row1::before { box-shadow: 0 .5px 0 var(--mk-hair); }

    /* Controles con relleno gris translúcido (iOS) */
    .vv-mk-search { height: 38px; border: 0; border-radius: 11px; background: var(--mk-fill); padding-left: .7rem; }
    .vv-mk-search:focus-within { box-shadow: none; background: rgba(118, 118, 128, .16); }
    .vv-mk-search input { font-size: 16px; } /* evita el zoom de iOS al enfocar */
    .vv-mk-filter-btn { height: 38px; border: 0; border-radius: 11px; background: var(--mk-fill); padding: 0 .8rem; }
    .vv-mk-toolbar .vv-loc-near { display: none; }
    .vv-mk-toolbar .vv-loc-trigger {
        height: 38px; padding: 0 .75rem; border: 0; border-radius: 11px; background: var(--mk-fill); font-size: .86rem;
        color: var(--vv-ink);
    }
    /* Pin de ubicación (distinto del icono de filtros); se tiñe cuando hay una ciudad elegida */
    .vv-mk-toolbar .vv-loc-gear { display: none; }
    .vv-mk-toolbar .vv-loc-pin { display: inline; font-size: 1rem; color: var(--vv-muted); }
    .vv-mk-toolbar .vv-loc-trigger.has-city { background: rgba(14, 90, 85, .12); color: var(--vv-brand); }
    .vv-mk-toolbar .vv-loc-trigger.has-city .vv-loc-pin { color: var(--vv-brand); }
    .vv-mk-toolbar .vv-loc-name { text-decoration: none; }

    /* Hoja inferior de filtros (estilo iOS) */
    .vv-mk-backdrop { position: fixed; inset: 0; z-index: 1001; background: rgba(0, 0, 0, .35); animation: vv-fade .2s ease-out; }
    .vv-mk-aside {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 1002; margin: 0;
        max-height: 82vh; max-height: 82dvh; border-radius: 14px 14px 0 0; border: 0;
        background: #f2f2f7; box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
        transform: translateY(101%); visibility: hidden;
        transition: transform .38s var(--mk-ease), visibility .38s;
    }
    .vv-mk-aside.is-open { transform: none; visibility: visible; }
    .vv-mk-aside-head {
        position: relative; display: grid; grid-template-columns: 1fr auto 1fr;
        padding: 1.15rem 1rem .75rem; border-bottom: .5px solid var(--mk-hair);
    }
    .vv-mk-aside-head::before {
        content: ""; position: absolute; top: .4rem; left: 50%; transform: translateX(-50%);
        width: 36px; height: 5px; border-radius: 99px; background: rgba(60, 60, 67, .3);
    }
    .vv-mk-aside-head strong { order: 0; flex: none; font-size: 1rem; }
    .vv-mk-aside-head strong i { display: none; }
    .vv-mk-reset { justify-self: start; font-weight: 500; font-size: .95rem; }
    .vv-mk-done { display: inline; justify-self: end; font-weight: 700; font-size: .95rem; }
    .vv-mk-aside-body { padding: 0 1rem 1rem; }
    .vv-mk-group legend { margin: .2rem 0 .45rem .2rem; }

    /* Grupos tipo "lista agrupada" de iOS */
    .vv-mk-cats {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .45rem;
    }
    .vv-mk-cat { background: #fff; padding: .55rem .6rem; }
    .vv-mk-cat:has(input:checked) { box-shadow: inset 0 0 0 2px var(--vv-hot); }
    .vv-mk-price { background: #fff; border-radius: 12px; padding: .7rem; }
    .vv-mk-price input { font-size: 16px; background: #f2f2f7; border-color: transparent; }

    .vv-mk-aside-foot {
        display: block; padding: .7rem 1rem calc(.8rem + env(safe-area-inset-bottom));
        border-top: .5px solid var(--mk-hair); background: rgba(242, 242, 247, .94);
    }
    .vv-mk-apply {
        width: 100%; border: 0; cursor: pointer; padding: .85rem; border-radius: 14px;
        background: var(--vv-brand); color: #fff; font: inherit; font-weight: 700; font-size: 1rem;
    }

    html.vv-mk-lock, html.vv-mk-lock body { overflow: hidden; }
}

/* Teléfono: botones de la barra solo con icono */
@media (max-width: 640px) {
    .vv-mk-head { padding: .6rem 0 .5rem; }
    .vv-mk-head p { font-size: .86rem; }
    .vv-mk-row1 { gap: .45rem; padding: .5rem 0; }
    .vv-mk-filter-txt { display: none; }
    .vv-mk-filter-btn { width: 38px; padding: 0; justify-content: center; }
    .vv-mk-badge { position: absolute; top: -4px; right: -4px; box-shadow: 0 0 0 2px #f3f6f5; }
    .vv-mk-toolbar .vv-loc-trigger { width: 38px; padding: 0; justify-content: center; }
    .vv-mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .vv-mk-meta { margin: .75rem 0 .7rem; }
    .vv-mk-sep { padding: .75rem .85rem; }
}

@media (min-width: 1440px) {
    .vv-mk-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .vv-mk-aside, .vv-mk-row2 { transition: none; }
}
