/**
 * Header Builder Enterprise - Mega menú
 * Mobile-first: base = móvil, min-width para tablet/desktop
 */

/* Mega menú overlay - z-index 1001 (sobre header) para que sea visible en móvil */
/* Móvil: debajo de las 2 filas del header */
.hbe-megamenu {
    position: fixed;
    top: calc(var(--hbe-height, 70px) + 56px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    width: 100vw;
    max-width: 100%;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s, transform 0.25s ease;
}

.hbe-megamenu.is-visible {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.hbe-megamenu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: -1;
}

/* Desktop: 1 fila, mega menú debajo del header */
@media (min-width: 1025px) {
    .hbe-megamenu {
        top: var(--hbe-height, 70px);
    }
}

/* Panel del mega menú */
.hbe-megamenu-panel {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Móvil: padding reducido */
.hbe-megamenu-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Grid de categorías - móvil: 2 columnas */
.hbe-megamenu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 600px) {
    .hbe-megamenu-cat-image {
        width: 72px;
        height: 72px;
    }
    .hbe-megamenu-content {
        padding: 24px 20px;
    }

    .hbe-megamenu-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (min-width: 900px) {
    .hbe-megamenu-cat-image {
        width: 80px;
        height: 80px;
    }

    .hbe-megamenu-cat-name {
        font-size: 0.95rem;
    }
    .hbe-megamenu-content {
        padding: 32px 24px;
    }

    .hbe-megamenu-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 24px;
    }
}

.hbe-megamenu-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hbe-megamenu-cat-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: #1f2937;
    transition: transform 0.2s ease, color 0.2s ease;
}

.hbe-megamenu-cat-link:hover {
    color: #2563eb;
    transform: translateY(-2px);
}

.hbe-megamenu-cat-image {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 4px;
}

.hbe-megamenu-cat-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hbe-megamenu-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.hbe-megamenu-cat-name {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}

/* Subcategorías */
.hbe-megamenu-subcats {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hbe-megamenu-subcats li {
    margin: 0;
}

.hbe-megamenu-subcats a {
    display: block;
    padding: 6px 0;
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.hbe-megamenu-subcats a:hover {
    color: #2563eb;
    padding-left: 4px;
}

/* El mega menú se posiciona fijo y centrado en viewport (definido arriba) */
.hbe-megamenu-trigger {
    position: relative;
}
