/* ------------------------------------------------------------------
   MBEAT Category Carousel + Modal - CSS completo y corregido
   ------------------------------------------------------------------ */

/* --- 0. Reset / helpers --- */
.mbeat-carousel-wrapper,
.mbeat-carousel-track,
.mbeat-cat-item { box-sizing: border-box; }

/* --- 1. CONTENEDOR PRINCIPAL --- */
.mbeat-carousel-wrapper {
    width: 100% !important;
    background: transparent !important;
    overflow: hidden !important;
    z-index: 99999 !important; /* Debe ser MENOR que el modal */
    position: relative; /* referencia para elementos absolutos si aplica */
}

/* Track horizontal */
.mbeat-carousel-track {
    display: flex !important;
    flex-wrap: nowrap !important;
    height: 100% !important;
    will-change: transform;
}

/* Item genérico */
.mbeat-cat-item {
    flex: 0 0 120px !important;
    width: 120px !important;
    min-width: 120px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    background: transparent !important;
    padding: 10px !important;
    transition: background 0.25s ease, transform 0.15s ease;
    user-select: none;
}

/* Hover */
.mbeat-cat-item:hover {
    background: rgba(0,0,0,0.04) !important;
    transform: translateY(-2px);
}

/* Texto / label dentro del item */
.mbeat-cat-item span {
    font-size: 11px !important;
    color: #fff !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    text-align: center !important;
}

/* Cuando el item es link directo, que el anchor ocupe todo el bloque */
/* (Se asegura en HTML/JS que exista <a> dentro para items sin hijos) */
.mbeat-cat-item a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-decoration: none;
    width: 100%;
    height: 100%;
    color: inherit;
}

/* Ocultar imágenes en desktop en menú principal (opcional) */
@media (min-width: 1025px) {
    .mbeat-cat-item img {
        display: none !important;
    }

    .mbeat-cat-item span {
        font-size: 12px !important;
    }

    .mbeat-carousel-track {
        justify-content: center !important;
        transform: none !important;
    }
}

/* --- 2. DISEÑO PARA MÓVIL (Carrusel fijo abajo) --- */
@media (max-width: 1024px) {
    .mbeat-carousel-wrapper {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        height: 85px !important;
        background: #000 !important;
        z-index: 99999 !important; /* menor que el modal */
        border-top: 1px solid #333 !important;
        border-bottom: none !important;
        overflow: hidden !important;
        width: 100% !important;
        margin: 0 !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    .mbeat-carousel-track {
        display: flex !important;
        flex-wrap: nowrap !important;
        height: 100% !important;
    }

    .mbeat-carousel-wrapper .mbeat-cat-item img {
        width: 35px !important;
        height: 35px !important;
        display: block !important;
        margin: 0 auto 4px auto !important;
        object-fit: contain !important;
        border-radius: 6px;
    }

    .mbeat-carousel-wrapper .mbeat-cat-item {
        flex: 0 0 90px !important;
        width: 90px !important;
        min-width: 90px !important;
        height: 100% !important;
        padding: 8px 5px !important;
        border-right: 1px solid #1a1a1a !important;
    }

    .mbeat-carousel-wrapper .mbeat-cat-item span {
        font-size: 9px !important;
        color: #fff !important;
        white-space: normal !important;
        word-break: break-word !important;
        width: 80px !important;
        text-align: center !important;
        line-height: 1.1 !important;
    }

    /* Dejar espacio al body para que el footer fijo no tape contenido */
    body {
        padding-bottom: 85px !important;
        padding-top: 0 !important;
    }
}

/* --- 3. SHORTCODE INDIVIDUAL - tamaño compacto y responsive --- */
.mbeat-single-cat-wrapper {
    display: block;
    margin: 20px 0;
    text-align: center;
}

/* Items individuales (ej. en páginas de categoría o bloques) */
.mbeat-single-cat-wrapper .mbeat-cat-item {
    position: relative !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: auto !important;
    background: transparent !important;
    padding: 0 !important;
}

/* Imagen más pequeña por defecto para items individuales */
.mbeat-single-cat-wrapper .mbeat-cat-item img {
    display: block !important;
    width: 120px !important;
    height: 120px !important;
    margin: 0 auto 12px auto !important;
    object-fit: cover;
    border-radius: 12px;
}

/* Texto de item individual */
.mbeat-single-cat-wrapper .mbeat-cat-item span {
    color: #333 !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
}

/* Hover neutro */
.mbeat-single-cat-wrapper .mbeat-cat-item:hover {
    background: transparent !important;
}

/* Más compacto en pantallas pequeñas */
@media (max-width: 768px) {
    .mbeat-single-cat-wrapper .mbeat-cat-item img {
        width: 90px !important;
        height: 90px !important;
    }
    .mbeat-single-cat-wrapper .mbeat-cat-item span {
        font-size: 14px !important;
    }
    .mbeat-single-cat-wrapper { margin: 12px 0; }
}

/* Asegurar que los anchors dentro de items individuales cubran todo el bloque */
.mbeat-single-cat-wrapper .mbeat-cat-item a {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

/* --- 4. MODAL --- */
.mbeat-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000000 !important; /* MUCHO mayor que el footer/carrusel */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    padding: env(safe-area-inset-top) env(safe-area-inset-left) env(safe-area-inset-bottom) env(safe-area-inset-right);
    -webkit-overflow-scrolling: touch;
}

.mbeat-modal.active { display: flex !important; pointer-events: auto; }

/* Caja del modal: centrada y con límite de altura para móviles */
.mbeat-modal-box {
    background: #fff;
    width: 92%;
    max-width: 1000px;
    max-height: calc(100vh - 120px); /* deja espacio visual */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

/* Header y close */
.mbeat-modal-header {
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}
.mbeat-modal-header h3 {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 18px;
    margin: 0;
    color: #000;
}
.mbeat-modal-close {
    font-size: 26px;
    background: none;
    border: none;
    cursor: pointer;
    color: #000;
}

/* Body con scroll interno */
.mbeat-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

/* Grid de subcategorías dentro del modal */
.mbeat-subcats ul {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    list-style: none;
    padding: 0;
    margin: 0;
}
.mbeat-subcats li a {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    padding: 12px !important;
    background: #f9f9f9 !important;
    text-decoration: none !important;
    border: 1px solid #eee !important;
    border-radius: 8px;
    color: #111 !important;
}
.mbeat-subcats li a:hover {
    background: #111 !important;
}
.mbeat-subcats li a:hover span {
    color: #fff !important;
}
.mbeat-subcats img {
    width: 60px !important;
    height: 60px !important;
    margin-bottom: 10px !important;
    display: block !important;
    object-fit: cover;
    border-radius: 8px;
}
.mbeat-subcats span {
    font-size: 14px !important;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

/* Responsive grid */
@media (max-width: 768px) {
    .mbeat-subcats ul { grid-template-columns: repeat(2, 1fr); }
    .mbeat-modal-box { max-width: 92%; }
    .mbeat-modal-body { padding: 14px; max-height: calc(100vh - 160px); }
}

/* --- 5. UTILIDADES: visibilidad, clases para JS --- */
/* Si usas clases .has-children o .no-children en los items, que el cursor sea coherente */
.mbeat-cat-item.has-children { cursor: pointer !important; }
.mbeat-cat-item.no-children { cursor: pointer !important; }

/* Si hay overlay activo, evitar scroll de fondo (clase añadida vía JS) */
body.mbeat-modal-open {
    overflow: hidden;
    touch-action: none;
}

/* Asegurar que el overlay ocupa safe-area en iOS */
@supports(padding: max(0px)) {
    .mbeat-modal { padding-bottom: env(safe-area-inset-bottom); }
}

/* --- 6. Ajustes finales estéticos --- */
.mbeat-subcats li a span,
.mbeat-cat-item span { transition: color 0.18s ease, background 0.18s ease; }

/* Pequeños fixes para evitar que el modal quede debajo de elementos fijos */
.mbeat-modal,
.mbeat-modal * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* --- FIN DEL CSS --- */