/* Módulo: categorías
   Parcial asociado: resources/views/catalogo/partials/categorias.blade.php
   Responsabilidad:
   - barra horizontal desktop (.categoria-scroll, .categoria-item)
   - filtro móvil integrado en buscador (.pf-btn-categorias-unificado), overlay, drawer (.pf-*)
   Z-index referencia: barra móvil 1002; overlay 9998; drawer 9999 (por debajo de modales 10000)
*/
.categoria-scroll {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 15px;
    background: #fff;
    margin: 20px 0;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.categoria-scroll::-webkit-scrollbar {
    height: 6px;
}

.categoria-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.categoria-scroll::-webkit-scrollbar-thumb {
    background: var(--rojo);
    border-radius: 10px;
}

.categoria-item {
    background: var(--rojo);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    white-space: nowrap;
    transition: all 0.3s;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: -0.01em;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.categoria-item:hover,
.categoria-item.active {
    background: var(--rojo-oscuro);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* =========================================
   CATEGORÍAS MOBILE — filtro integrado en buscador
========================================= */

.pf-btn-categorias-unificado {
    display: none;
}

.pf-categoria-filtro-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #22c55e;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

@media (max-width: 768px) {
    .pf-categorias-desktop-wrap {
        display: none;
    }

    .categoria-scroll {
        display: none !important;
    }

    .container.mt-4.mb-0 {
        margin-top: 0.5rem !important;
    }

    .pf-btn-categorias-unificado {
        position: relative;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        padding: 0;
        border: 0;
        border-radius: 16px;
        background: var(--rojo);
        color: #fff;
        box-shadow:
            0 6px 16px rgba(211, 47, 47, 0.22),
            0 2px 6px rgba(211, 47, 47, 0.12);
        cursor: pointer;
    }

    .pf-btn-categorias-unificado__icon {
        width: 20px;
        height: 20px;
    }

    .pf-btn-categorias-unificado:hover {
        background: var(--rojo-oscuro);
    }

    .pf-btn-categorias-unificado:active {
        transform: scale(0.95);
    }

    .pf-btn-categorias-unificado:focus-visible {
        outline: 2px solid var(--rojo);
        outline-offset: 2px;
    }

    .pf-btn-categorias-unificado.is-active {
        box-shadow:
            0 10px 22px rgba(211, 47, 47, 0.28),
            0 2px 6px rgba(211, 47, 47, 0.14);
    }

    .pf-btn-categorias-unificado.has-filter {
        background: linear-gradient(135deg, var(--rojo), var(--rojo-oscuro));
    }
}

@media (max-width: 576px) {
    .categoria-scroll {
        top: 6px;
        padding: 10px;
    }
}

/* Overlay con blur */
.pf-overlay-categorias {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
    z-index: 9998;
    pointer-events: none;
}

.pf-overlay-categorias.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Panel categorías móvil — 60% ancho × 95% alto */
.pf-drawer-categorias {
    position: fixed;
    top: 50%;
    left: 12px;
    width: 60vw;
    height: 95vh;
    height: 95dvh;
    max-height: 95vh;
    max-height: 95dvh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(241, 245, 249, 0.8);
    border-radius: 24px;
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.14),
        0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translate3d(calc(-100% - 12px), -50%, 0) scale(0.96);
    transform-origin: left center;
    opacity: 0;
    visibility: hidden;
    will-change: transform, opacity;
    transition:
        transform .32s cubic-bezier(.22, 1, .36, 1),
        opacity .24s ease,
        visibility .24s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pf-drawer-categorias.is-open {
    transform: translate3d(0, -50%, 0) scale(1);
    opacity: 1;
    visibility: visible;
}

.pf-drawer-categorias.is-swiping {
    transition: none;
}

.pf-drawer-categorias__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid #f1f5f9;
}

.pf-drawer-categorias__title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.pf-drawer-categorias__close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s ease, color .2s ease;
}

.pf-drawer-categorias__close:hover {
    background: #e2e8f0;
    color: #475569;
}

.pf-drawer-categorias__close:focus-visible {
    outline: 2px solid #d32f2f;
    outline-offset: 2px;
}

.pf-drawer-categorias__body {
    flex: 1;
    min-height: 0;
    padding: 10px 12px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}

.pf-drawer-categorias__body::-webkit-scrollbar {
    width: 4px;
}

.pf-drawer-categorias__body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
}

/* Item móvil — premium PWA */
.pf-categoria-mobile-item {
    width: 100%;
    border: 0;
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #334155;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    text-align: left;
    transition: background .2s ease, color .2s ease, box-shadow .2s ease;
    cursor: pointer;
}

.pf-categoria-mobile-item__text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pf-categoria-mobile-item:hover:not(.active) {
    background: #f1f5f9;
}

/* Activa */
.pf-categoria-mobile-item.active {
    background: var(--rojo);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(211, 47, 47, 0.22);
}

/* Desktop: ocultar drawer/botón */
@media (min-width: 769px) {
    .pf-overlay-categorias,
    .pf-drawer-categorias {
        display: none !important;
    }
}
