/* ════════════════════════════════════════════════════════════════════
   IMBATIK · MEGAMENÚ SERVICIOS
   ════════════════════════════════════════════════════════════════════

   Estructura:
     .ih-megamenu               → container global (oculto por defecto)
       .ih-megamenu__overlay    → click-out para cerrar (solo mobile/tablet)
       .ih-megamenu__panel      → contenido visible
         .ih-megamenu__mobile-head → header con título y X (solo <992px)
         .ih-megamenu__inner    → padding interior
           .ih-megamenu__columns → grid de columnas temáticas
             .ih-mm-col         → columna (E-commerce / Marketing / Creatividad)
               .ih-mm-col__head → cabecera con icon + label
               .ih-mm-col__hubs → lista de hubs principales
                 .ih-mm-hub     → bloque hub (PrestaShop, Shopify, SEO, ...)
                   .ih-mm-hub__head     → cabecera clicable
                   .ih-mm-hub__children → lista de hijas (Barcelona, Girona, etc.)
           .ih-mm-sectors       → banda de chips por sector
           .ih-mm-footer        → CTAs finales

   Breakpoints:
     ≥1280px: panel ancho, 3 columnas, todas las hijas visibles
     992-1279px: 3 columnas más compactas
     768-991px: drawer lateral derecho (max-width 480px), acordeón
     <768px: drawer fullscreen, acordeón
   ════════════════════════════════════════════════════════════════════ */

/* ═══ Container global ═══ */
.ih-megamenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity .25s ease, visibility 0s linear .25s;
}
.ih-megamenu.is-open {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
    transition: opacity .3s ease, visibility 0s linear 0s;
}

/* Overlay para click-out (solo visible en mobile/tablet) */
.ih-megamenu__overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .25s ease;
}
.ih-megamenu.is-open .ih-megamenu__overlay {
    opacity: 1;
}

/* Panel principal */
.ih-megamenu__panel {
    position: absolute;
    background: #ffffff;
    box-shadow: 0 24px 64px rgba(10, 14, 26, .14),
                0 8px 24px rgba(10, 14, 26, .06);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Header del panel en mobile/tablet */
.ih-megamenu__mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}
.ih-megamenu__mobile-title {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #0a0e1a;
    letter-spacing: -0.01em;
}
.ih-megamenu__close {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(15, 23, 42, .08);
    background: #fff;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #0a0e1a;
    transition: background .2s, border-color .2s;
}
.ih-megamenu__close:hover {
    background: rgba(15, 23, 42, .04);
    border-color: rgba(15, 23, 42, .14);
}
.ih-megamenu__close .material-symbols-outlined {
    font-size: 22px;
}

/* Inner con padding */
.ih-megamenu__inner {
    padding: 32px 28px 24px;
    font-family: 'Inter', system-ui, sans-serif;
}

/* ═══ Grid de columnas ═══ */
.ih-megamenu__columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 36px;
    margin-bottom: 28px;
}

/* ═══ Columna individual ═══ */
.ih-mm-col[data-color="blue"]   { --mm-accent: #5C82F2; --mm-tint: rgba(92,130,242,.10); }
.ih-mm-col[data-color="coral"]  { --mm-accent: #FF7B72; --mm-tint: rgba(255,123,114,.10); }
.ih-mm-col[data-color="green"]  { --mm-accent: #16a571; --mm-tint: rgba(111,219,165,.16); }
.ih-mm-col[data-color="yellow"] { --mm-accent: #c2410c; --mm-tint: rgba(255,210,102,.20); }

.ih-mm-col__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--mm-tint);
}
.ih-mm-col__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--mm-tint);
    color: var(--mm-accent);
    flex-shrink: 0;
}
.ih-mm-col__icon .material-symbols-outlined {
    font-size: 18px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}
.ih-mm-col__label {
    font-size: 11px;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0;
}

/* ═══ Hubs ═══ */
.ih-mm-col__hubs {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ih-mm-hub__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 10px;
    text-decoration: none !important;
    color: #0a0e1a;
    transition: background .2s;
    margin: -10px -8px 0;
}
.ih-mm-hub__head:hover {
    background: var(--mm-tint);
}
.ih-mm-hub__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--mm-tint);
    color: var(--mm-accent);
    flex-shrink: 0;
    margin-top: 1px;
}
.ih-mm-hub__icon .material-symbols-outlined {
    font-size: 20px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}
.ih-mm-hub__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.ih-mm-hub__title {
    font-size: 15px;
    font-weight: 700;
    color: #0a0e1a;
    line-height: 1.3;
}
.ih-mm-hub__desc {
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    line-height: 1.4;
}
.ih-mm-hub__chevron {
    display: none; /* solo visible en mobile como toggle */
    align-items: center;
    color: #94a3b8;
    margin-left: auto;
    transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.ih-mm-hub__chevron .material-symbols-outlined {
    font-size: 22px;
}

/* Lista de hijas */
.ih-mm-hub__children {
    list-style: none;
    margin: 8px 0 0;
    padding: 0 0 0 44px; /* alineado bajo el texto, no bajo el icon */
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ih-mm-hub__children li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: #475569;
    text-decoration: none !important;
    transition: color .2s, background .2s, padding-left .2s;
}
.ih-mm-hub__children li a:hover {
    color: var(--mm-accent);
    background: var(--mm-tint);
    padding-left: 12px;
}
.ih-mm-hub__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════════
   LAYOUT: CARDS (panel de Sectores)
   Grid de cards visuales con icono + título + descripción + flecha.
   ════════════════════════════════════════════════════════════════════ */

.ih-mm-cards__intro {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
}
.ih-mm-cards__eyebrow {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    color: #5C82F2;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.ih-mm-cards__headline {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #0a0e1a;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.ih-mm-cards__subhead {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    line-height: 1.45;
}

.ih-mm-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.ih-mm-cards[data-count="4"] {
    grid-template-columns: repeat(4, 1fr);
}
.ih-mm-cards[data-count="2"] {
    grid-template-columns: repeat(2, 1fr);
    max-width: 720px;
}

.ih-mm-card[data-color="blue"]   { --mm-card-accent: #5C82F2; --mm-card-tint: rgba(92,130,242,.10); }
.ih-mm-card[data-color="coral"]  { --mm-card-accent: #FF7B72; --mm-card-tint: rgba(255,123,114,.10); }
.ih-mm-card[data-color="green"]  { --mm-card-accent: #16a571; --mm-card-tint: rgba(111,219,165,.16); }
.ih-mm-card[data-color="yellow"] { --mm-card-accent: #c2410c; --mm-card-tint: rgba(255,210,102,.22); }

.ih-mm-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 18px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 14px;
    text-decoration: none !important;
    transition: all .25s cubic-bezier(.16,1,.3,1);
    position: relative;
}
.ih-mm-card:hover {
    border-color: var(--mm-card-accent);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(10, 14, 26, .08),
                0 4px 8px rgba(10, 14, 26, .04);
}
.ih-mm-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: var(--mm-card-tint);
    color: var(--mm-card-accent);
    flex-shrink: 0;
    transition: background .2s, transform .2s, color .2s;
}
.ih-mm-card:hover .ih-mm-card__icon {
    background: var(--mm-card-accent);
    color: #fff;
    transform: scale(1.05);
}
.ih-mm-card__icon .material-symbols-outlined {
    font-size: 22px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}
.ih-mm-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ih-mm-card__title {
    font-size: 15px;
    font-weight: 700;
    color: #0a0e1a;
    line-height: 1.3;
}
.ih-mm-card__desc {
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    line-height: 1.4;
}
.ih-mm-card__arrow {
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
    margin-top: 2px;
    transition: color .2s, transform .2s;
}
.ih-mm-card:hover .ih-mm-card__arrow {
    color: var(--mm-card-accent);
    transform: translate(2px, -2px);
}
.ih-mm-card__arrow .material-symbols-outlined {
    font-size: 18px;
}

/* Cards responsive */
@media (max-width: 1199.98px) {
    .ih-mm-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 767.98px) {
    .ih-mm-cards {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .ih-mm-cards__intro {
        margin-bottom: 18px;
    }
    .ih-mm-cards__headline {
        font-size: 19px;
    }
    .ih-mm-cards__subhead {
        font-size: 13px;
    }
}

/* ═══ Banda de sectores (LEGACY — ya no usado, se mantiene por si filter lo añade) ═══ */
.ih-mm-sectors {
    padding: 22px 0;
    border-top: 1px solid rgba(15, 23, 42, .08);
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    margin-bottom: 22px;
}
.ih-mm-sectors__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.ih-mm-sectors__label .material-symbols-outlined {
    font-size: 18px;
    color: #FFD266;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}
.ih-mm-sectors__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ih-mm-sector-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    color: #0a0e1a;
    text-decoration: none !important;
    transition: all .25s cubic-bezier(.16,1,.3,1);
}
.ih-mm-sector-chip:hover {
    background: #fff;
    border-color: #FFD266;
    color: #c2410c;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 210, 102, .25);
}
.ih-mm-sector-chip .material-symbols-outlined {
    font-size: 16px;
    color: #c2410c;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}

/* ═══ Footer CTAs ═══ */
.ih-mm-footer {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.ih-mm-footer__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    transition: all .25s cubic-bezier(.16,1,.3,1);
}
.ih-mm-footer__cta--primary {
    background: linear-gradient(135deg, #5C82F2 0%, #3a5fd4 100%);
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(92, 130, 242, .35);
}
.ih-mm-footer__cta--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(92, 130, 242, .45);
    color: #fff !important;
}
.ih-mm-footer__cta--ghost {
    color: #0a0e1a !important;
    border: 1px solid rgba(15, 23, 42, .12);
    background: #fff;
}
.ih-mm-footer__cta--ghost:hover {
    background: #f8fafc;
    border-color: rgba(15, 23, 42, .22);
    color: #0a0e1a !important;
}
.ih-mm-footer__cta .material-symbols-outlined {
    font-size: 18px;
}

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE — DESKTOP GRANDE (≥1280px)
   Panel fullwidth, 3 columnas, posicionado bajo el header
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 992px) {
    .ih-megamenu {
        position: absolute; /* anclado al #masthead (que es position:relative) */
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: calc(100vh - 100px);
        background: transparent;
        pointer-events: none;
        z-index: 9999;
        /* Reset properties que podría heredar del position:fixed mobile */
        bottom: auto;
    }
    .ih-megamenu.is-open {
        pointer-events: auto;
    }
    .ih-megamenu__overlay {
        display: none;
    }
    .ih-megamenu__panel {
        position: relative;
        max-width: 1280px;
        margin: 0 auto;
        border-radius: 0 0 24px 24px;
        transform: translateY(-10px);
        opacity: 0;
        transition: transform .25s cubic-bezier(.16,1,.3,1), opacity .25s ease;
    }
    .ih-megamenu.is-open .ih-megamenu__panel {
        transform: translateY(0);
        opacity: 1;
    }
    .ih-megamenu__mobile-head {
        display: none;
    }
    .ih-megamenu__inner {
        padding: 36px 40px 28px;
    }

    /* En desktop, las hijas siempre visibles (no acordeón) */
    .ih-mm-hub__children {
        display: flex !important;
        max-height: none !important;
    }
    .ih-mm-hub__chevron {
        display: none !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET / MOBILE (<992px)
   Drawer lateral derecho, acordeón con chevrons
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .ih-megamenu__panel {
        top: 0;
        right: 0;
        width: 100%;
        max-width: 480px;
        height: 100%;
        transform: translateX(100%);
        transition: transform .35s cubic-bezier(.16,1,.3,1);
    }
    .ih-megamenu.is-open .ih-megamenu__panel {
        transform: translateX(0);
    }

    .ih-megamenu__inner {
        padding: 22px 22px 32px;
    }

    /* Columnas apiladas */
    .ih-megamenu__columns {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 20px;
    }

    /* Cada columna como acordeón con borde suave */
    .ih-mm-col {
        background: #fff;
        border: 1px solid rgba(15, 23, 42, .08);
        border-radius: 14px;
        padding: 16px 18px;
    }
    .ih-mm-col__head {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    /* Hub head clicable como toggle */
    .ih-mm-hub__chevron {
        display: inline-flex;
    }
    .ih-mm-hub.is-expanded .ih-mm-hub__chevron {
        transform: rotate(90deg);
    }

    /* Hijas ocultas por defecto en mobile */
    .ih-mm-hub__children {
        max-height: 0;
        overflow: hidden;
        margin: 0;
        padding: 0 0 0 44px;
        transition: max-height .3s cubic-bezier(.16,1,.3,1),
                    margin-top .3s,
                    padding-bottom .3s;
    }
    .ih-mm-hub.is-expanded .ih-mm-hub__children {
        max-height: 500px;
        margin-top: 8px;
        padding-bottom: 8px;
    }

    /* Sectores */
    .ih-mm-sectors {
        padding: 18px 0;
        margin-bottom: 18px;
    }
    .ih-mm-sectors__list {
        gap: 6px;
    }
    .ih-mm-sector-chip {
        padding: 7px 12px;
        font-size: 12.5px;
    }

    /* Footer CTAs apilados a full width */
    .ih-mm-footer {
        flex-direction: column;
        gap: 10px;
    }
    .ih-mm-footer__cta {
        justify-content: center;
        width: 100%;
        padding: 14px 22px;
    }
}

/* ════════════════════════════════════════════════════════════════════
   MOBILE PEQUEÑO (<480px)
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 479.98px) {
    .ih-megamenu__panel {
        max-width: 100%;
    }
    .ih-megamenu__inner {
        padding: 18px 16px 26px;
    }
    .ih-mm-col {
        padding: 14px 16px;
    }
    .ih-mm-hub__title {
        font-size: 14px;
    }
    .ih-mm-hub__desc {
        font-size: 12px;
    }
    .ih-mm-hub__children li a {
        font-size: 13px;
    }
}

/* ════════════════════════════════════════════════════════════════════
   INTEGRACIÓN CON EL HEADER NATIVO
   El item "Servicios" del menú debe tener su chevron y estado activo
   ════════════════════════════════════════════════════════════════════ */
.ih-megamenu-trigger {
    cursor: pointer;
}
.ih-megamenu-trigger .ih-megamenu-trigger__chevron {
    display: inline-flex;
    margin-left: 4px;
    transition: transform .25s cubic-bezier(.16,1,.3,1);
    vertical-align: middle;
}
.ih-megamenu-trigger .ih-megamenu-trigger__chevron .material-symbols-outlined {
    font-size: 18px;
}
.ih-megamenu-trigger.is-active .ih-megamenu-trigger__chevron {
    transform: rotate(180deg);
}

/* ════════════════════════════════════════════════════════════════════
   OCULTAR DROPDOWN Y CHEVRON NATIVOS DEL ITEM SERVICIOS

   El theme tiene CSS propio que añade:
   - Un chevron nativo via ::before content:'expand_more' (línea 218 header.php)
   - Un dropdown .sub-menu con CSS específico (líneas 236+ header.php)

   Los ocultamos con !important agresivo solo en el item con clase
   ih-megamenu-trigger (que el JS añade al item Servicios).
   ════════════════════════════════════════════════════════════════════ */

/* Ocultar chevron nativo del theme (::before generado por CSS) */
#masthead #site-navigation > ul > li.ih-megamenu-trigger > a::before {
    display: none !important;
    content: none !important;
}

/* Ocultar el dropdown nativo .sub-menu en este item */
#masthead #site-navigation > ul > li.ih-megamenu-trigger > .sub-menu,
#masthead #site-navigation > ul > li.ih-megamenu-trigger:hover > .sub-menu,
#masthead #site-navigation > ul > li.ih-megamenu-trigger:focus-within > .sub-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ocultar chevron nativo inyectado por JS del theme (.sub-toggle) */
#masthead #site-navigation > ul > li.ih-megamenu-trigger > .sub-toggle {
    display: none !important;
}

/* Bloqueo de scroll cuando el megamenú está abierto en mobile */
body.has-megamenu-open {
    overflow: hidden;
}

/* Respeto a prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .ih-megamenu,
    .ih-megamenu__overlay,
    .ih-megamenu__panel,
    .ih-mm-hub__chevron,
    .ih-mm-hub__children,
    .ih-mm-sector-chip,
    .ih-mm-footer__cta,
    .ih-megamenu-trigger__chevron {
        transition: opacity .15s ease, visibility 0s linear .15s !important;
    }
    .ih-megamenu.is-open .ih-megamenu__panel {
        transform: none !important;
    }
}
