/* ==========================================================================
   Navegación moderna de la carta: barra scrollspy sticky + secciones con salto
   Reemplaza el strip horizontal de categorías + modelo de filtro anterior.
   ========================================================================== */

:root {
    /* Desktop: solo hay que librar el navbar (~60px) al saltar a una sección.
       En móvil se sube a 112px (navbar + barra scrollspy) más abajo. */
    --spy-offset: 90px;
}

/* --------------------------------------------------------------------------
   Barra scrollspy
   -------------------------------------------------------------------------- */
.scrollspy-bar {
    position: sticky;
    top: 70px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.6rem 0.75rem;
}

.scrollspy-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    padding: 0.15rem 0.1rem;
    scrollbar-width: none;          /* Firefox */
}
.scrollspy-inner::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

.spy-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1.5px solid #ececec;
    background: #f7f7f9;
    color: #444;
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.spy-chip:hover { transform: translateY(-1px); border-color: var(--primary, #FF6B35); }

.spy-chip.active {
    background: var(--primary, #FF6B35);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}
.spy-chip.active .spy-count { background: rgba(255,255,255,.25); color: #fff; }

.spy-chip-text {
    display: inline-block;
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subcategoría: un pelín más chica y con punto guía */
.spy-chip.spy-sub {
    font-size: 0.85rem;
    padding: 0.45rem 0.8rem;
    background: #fff;
    border-style: dashed;
}
.spy-chip.spy-sub::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--secondary, #4ECDC4);
    margin-right: 0.1rem;
}

/* Chips especiales (filtran, no saltan) */
.spy-chip.spy-special { background: #fff; border-color: #e6e6e6; }
.spy-chip.spy-special.active {
    background: var(--secondary, #4ECDC4);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.35);
}

.spy-count {
    background: rgba(0, 0, 0, 0.08);
    color: #666;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    min-width: 18px;
    text-align: center;
}

.spy-sep {
    flex: 0 0 auto;
    width: 1px;
    height: 28px;
    background: #e0e0e0;
    margin: 0 0.25rem;
}

/* Botón móvil "todas las categorías" */
.spy-all-btn {
    flex: 0 0 auto;
    display: none;            /* visible solo en móvil */
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: var(--primary, #FF6B35);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Secciones de productos
   -------------------------------------------------------------------------- */
.menu-section {
    scroll-margin-top: var(--spy-offset);
    margin-bottom: 3.25rem;
}
.menu-section.is-subsection { margin-bottom: 2.5rem; }

/* Encabezado sticky tipo pastilla: queda pegado bajo la barra mientras
   recorres la categoría, dando contexto permanente. */
.menu-section-title {
    position: sticky;
    top: var(--spy-offset);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 1.5rem;          /* centrada (usar 0 0 para alinear a la izquierda) */
    padding: 0.35rem 1.05rem 0.35rem 0.4rem;
    font-size: 1.12rem;
    font-weight: 800;
    color: #1f1f1f;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(31, 31, 31, 0.12);
}
/* Icono dentro de un círculo con tinte del color de la categoría */
.menu-section-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 107, 53, 0.12);
    font-size: 1.05rem;
    line-height: 1;
}
.menu-section-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}
.menu-section.is-subsection .menu-section-title {
    font-size: 1rem;
    color: #555;
}
.menu-section.is-subsection .menu-section-icon {
    background: rgba(78, 205, 196, 0.16);
}
.menu-section-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary, #FF6B35);
    border-radius: 999px;
    padding: 2px 9px;
}
.menu-section.is-subsection .menu-section-count {
    background: var(--secondary, #4ECDC4);
}

/* Divisor de grupo padre (solo visual, no es target de scrollspy) */
/* Divisor de grupo padre: estilo clásico de carta (serif en cursiva,
   centrado y flanqueado por líneas finas; sin contorno ni fondo). */
.menu-parent-group {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin: 2.5rem 0 1.75rem;
}
.menu-parent-group::before,
.menu-parent-group::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(to right, transparent, #d8d2c8, transparent);
}
.menu-parent-group span {
    flex: 0 0 auto;
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #6d6257;
    white-space: nowrap;
    padding: 0 0.25rem;
}

/* --------------------------------------------------------------------------
   Modo filtro (búsqueda / chips especiales): oculta divisores de padre
   -------------------------------------------------------------------------- */
body.filter-mode .menu-parent-group { display: none !important; }

#no-results-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

/* --------------------------------------------------------------------------
   Offcanvas "Categorías" (lista completa con filtro rápido)
   -------------------------------------------------------------------------- */
.cat-offcanvas.offcanvas-bottom {
    height: 75vh;
    border-radius: 20px 20px 0 0;
}
.cat-quickfilter {
    border-radius: 999px;
    padding: 0.7rem 1.1rem;
    margin-bottom: 1rem;
}
.cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.cat-list-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid #eee;
    background: #fff;
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.cat-list-item:hover { background: #f7f7f9; border-color: var(--primary, #FF6B35); }
.cat-list-item.is-sub {
    margin-left: 1.25rem;
    font-weight: 500;
    font-size: 0.92rem;
}
.cat-list-item .badge {
    background: #eef0f2;
    color: #8a8f94;
    font-weight: 700;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 3px 9px;
}
/* La categoría activa sí resalta su conteo */
.cat-list-item.active .badge,
.cat-list-item:hover .badge {
    background: rgba(255, 107, 53, 0.12);
    color: var(--primary, #FF6B35);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    :root { --spy-offset: 112px; }
    .scrollspy-bar {
        top: 60px;
        padding: 0.5rem 0.5rem;
        position: sticky;          /* asegurar sticky también en tablets */
    }
    .spy-all-btn { display: inline-flex; }
    .menu-section-title { font-size: 1.25rem; }
    .menu-section.is-subsection .menu-section-title { font-size: 1.05rem; }
    .spy-chip { font-size: 0.88rem; padding: 0.5rem 0.85rem; }

    /* Pista de scroll: degradado a la derecha, antes del botón "Categorías" */
    .scrollspy-inner {
        position: relative;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
                mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
    }
    /* El botón "Categorías" se separa con su propio espacio y sombra */
    .spy-all-btn {
        margin-left: 0.15rem;
        box-shadow: -8px 0 10px -6px rgba(0, 0, 0, 0.12);
    }
}

/* --------------------------------------------------------------------------
   Layout con sidebar (desktop) + lista de categorías vertical
   -------------------------------------------------------------------------- */
.carta-layout { display: block; }

/* Sidebar oculto en móvil (se usa la barra horizontal scrollspy) */
.cat-sidebar { display: none; }

.cat-sidebar-inner { display: flex; flex-direction: column; gap: 2px; }

.side-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9aa0a6;
    padding: 0.25rem 0.85rem 0.6rem;
}

.side-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-left: 3px solid transparent;
    border-radius: 0 10px 10px 0;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.side-item:hover { background: #f5f5f7; }
.side-item.active {
    background: #fff4ee;
    color: var(--primary, #FF6B35);
    border-left-color: var(--primary, #FF6B35);
}

/* Subcategoría: indentada, más tenue, con punto guía */
.side-item.is-sub {
    padding-left: 1.7rem;
    font-weight: 500;
    font-size: 0.88rem;
    color: #6b7177;
}
.side-item.is-sub .side-item-text::before {
    content: "";
    display: inline-block;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--secondary, #4ECDC4);
    margin-right: 0.5rem;
    vertical-align: middle;
}
.side-item.is-sub.active { color: var(--primary, #FF6B35); }

.side-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-count {
    flex: 0 0 auto;
    font-size: 0.7rem;
    font-weight: 700;
    color: #8a8f94;
    background: #ececec;
    border-radius: 999px;
    padding: 1px 7px;
    min-width: 18px;
    text-align: center;
}
.side-item.active .side-count { background: var(--primary, #FF6B35); color: #fff; }
.side-item.spy-special.active .side-count { background: var(--secondary, #4ECDC4); color: #fff; }

.side-divider { height: 1px; background: #eee; margin: 0.6rem 0.85rem; }

/* Productos: sin container Bootstrap (el layout maneja ancho); padding propio */
.carta-products { padding-left: 15px; padding-right: 15px; }

/* En pantallas grandes el offcanvas se ve mejor como panel lateral */
@media (min-width: 992px) {
    .cat-offcanvas.offcanvas-bottom {
        height: 100%;
        max-width: 380px;
        left: auto;
        right: 0;
        border-radius: 20px 0 0 20px;
    }

    /* Layout de dos columnas: sidebar fijo + productos */
    .carta-layout {
        display: flex;
        align-items: flex-start;
        gap: 1.5rem;
        max-width: 1320px;
        margin: 0 auto;
        padding: 0 1rem;
    }
    .cat-sidebar {
        display: block;
        position: sticky;
        top: 90px;
        flex: 0 0 248px;
        width: 248px;
        max-height: calc(100vh - 110px);
        overflow-y: auto;
        padding: 1rem 0;
        scrollbar-width: thin;
    }
    .carta-products {
        flex: 1 1 auto;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
        padding-top: 1rem;
    }
    /* En desktop la barra horizontal se reemplaza por el sidebar */
    .scrollspy-bar { display: none; }
}
