/* =============================================================================
   rt-megamenu.css — Mega menú de categorías unificadas
   Paleta: #00B3A6 (primario teal), #1aba1a (secundario verde), neutros
   ============================================================================= */

/* ---- Variables ---- */
:root {
    --rtmm-primary:     #00B3A6;
    --rtmm-primary-dk:  #008a80;
    --rtmm-secondary:   #159e15;
    --rtmm-bg-toggle:   #00B3A6;
    --rtmm-bg-panel:    #ffffff;
    --rtmm-bg-roots:    #f5f7f7;
    --rtmm-bg-popular:  #fafafa;
    --rtmm-text:        #1f2937;
    --rtmm-text-muted:  #6b7280;
    --rtmm-text-light:  #9ca3af;
    --rtmm-border:      #e5e7eb;
    --rtmm-active-bg:   #e6f7f6;
    --rtmm-radius:      8px;
    --rtmm-shadow:      0 8px 32px rgba(0,0,0,.12);
    --rtmm-z:           9999;
}

/* ---- Contenedor ---- */
.rt-megamenu {
    position: relative;
    display: inline-block;
    font-family: inherit;
}

/* ---- Botón toggle ---- */
.rt-megamenu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--rtmm-bg-toggle);
    color: #fff;
    border: none;
    border-radius: var(--rtmm-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, box-shadow .2s;
    user-select: none;
}
.rt-megamenu__toggle:hover,
.rt-megamenu__toggle[aria-expanded="true"] {
    background: var(--rtmm-primary-dk);
    box-shadow: 0 2px 12px rgba(0,179,166,.3);
}
.rt-megamenu__toggle-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 18px;
}
.rt-megamenu__toggle-icon span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .25s, opacity .25s;
}
.rt-megamenu__toggle[aria-expanded="true"] .rt-megamenu__toggle-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.rt-megamenu__toggle[aria-expanded="true"] .rt-megamenu__toggle-icon span:nth-child(2) {
    opacity: 0;
}
.rt-megamenu__toggle[aria-expanded="true"] .rt-megamenu__toggle-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}
.rt-megamenu__toggle-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform .25s;
}
.rt-megamenu__toggle[aria-expanded="true"] .rt-megamenu__toggle-arrow {
    transform: rotate(180deg);
}

/* ---- Panel ---- */
.rt-megamenu__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: min(960px, 96vw);
    background: var(--rtmm-bg-panel);
    border: 1px solid var(--rtmm-border);
    border-radius: var(--rtmm-radius);
    box-shadow: var(--rtmm-shadow);
    z-index: var(--rtmm-z);
    animation: rtmm-fadein .18s ease;
}
.rt-megamenu__panel[hidden] {
    display: none;
}
@keyframes rtmm-fadein {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Inner: 3 columnas ---- */
.rt-megamenu__inner {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    min-height: 360px;
}

/* ---- Columna izquierda: raíces ---- */
.rt-megamenu__roots {
    list-style: none !important;
    margin: 0;
    padding: 8px 0;
    background: var(--rtmm-bg-roots);
    border-right: 1px solid var(--rtmm-border);
    border-radius: var(--rtmm-radius) 0 0 var(--rtmm-radius);
}
.rt-megamenu__root-item {
    margin: 0;
}
.rt-megamenu__root-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    color: var(--rtmm-text) !important;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
    gap: 6px;
}
.rt-megamenu__root-link:hover,
.rt-megamenu__root-item.is-active .rt-megamenu__root-link {
    background: var(--rtmm-active-bg);
    color: var(--rtmm-primary) !important;
}
.rt-megamenu__root-item.is-active .rt-megamenu__root-link {
    border-left: 3px solid var(--rtmm-primary);
    padding-left: 13px;
    font-weight: 600;
}
.rt-megamenu__chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--rtmm-text-light) !important;
    transition: color .15s;
}
.rt-megamenu__root-item.is-active .rt-megamenu__chevron,
.rt-megamenu__root-link:hover .rt-megamenu__chevron {
    color: var(--rtmm-primary) !important;
}

/* ---- Columna central: grupos de 2 niveles ---- */
.rt-megamenu__children-wrap {
    padding: 16px 20px;
    overflow-y: auto;
    max-height: 480px;
}
.rt-megamenu__children {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 20px 24px;
    align-content: start;
}
.rt-megamenu__children.is-active {
    display: grid;
}
.rt-megamenu__group {
    min-width: 0;
}
.rt-megamenu__group-title {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--rtmm-primary) !important;
    text-decoration: none;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--rtmm-primary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s;
}
.rt-megamenu__group-title:hover {
    color: var(--rtmm-primary-dk) !important;
}
.rt-megamenu__group-items {
    list-style: none !important;
    margin: 0;
    padding: 0;
}
.rt-megamenu__group-items li {
    margin: 0;
}
.rt-megamenu__group-items a {
    display: block;
    padding: 4px 0;
    font-size: 13px;
    color: var(--rtmm-text-muted) !important;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s;
}
.rt-megamenu__group-items a:hover {
    color: var(--rtmm-primary) !important;
}
.rt-megamenu__ver-mas a {
    color: var(--rtmm-secondary) !important;
    font-weight: 600;
    font-size: 12px;
}

/* ---- Columna derecha: populares ---- */
.rt-megamenu__popular {
    padding: 16px;
    background: var(--rtmm-bg-popular);
    border-left: 1px solid var(--rtmm-border);
    border-radius: 0 var(--rtmm-radius) var(--rtmm-radius) 0;
}
.rt-megamenu__popular-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--rtmm-primary) !important;
    margin: 0 0 12px;
}
.rt-megamenu__popular ul {
    list-style: none !important;
    margin: 0;
    padding: 0;
}
.rt-megamenu__popular li {
    margin: 0;
}
.rt-megamenu__popular a {
    display: block;
    padding: 7px 0;
    color: var(--rtmm-text-muted) !important;
    font-size: 13px;
    text-decoration: none;
    border-bottom: 1px solid var(--rtmm-border);
    transition: color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rt-megamenu__popular a:hover {
    color: var(--rtmm-primary) !important;
}
.rt-megamenu__popular li:last-child a {
    border-bottom: none;
}

/* ---- Responsive ---- */
/* =============================================================================
   RT MEGAMENU - MOBILE / TABLET
   ============================================================================= */

@media (max-width: 980px) {

    /* ---------------------------------------------------------
       Botón Categorías
       --------------------------------------------------------- */

    .rt-megamenu--mobile {
        display: block;
        width: 100%;
    }

    .rt-megamenu--mobile .rt-megamenu__toggle {
        width: 100%;
        justify-content: space-between;
        padding: 14px 16px;
        border-radius: 8px;
        font-size: 15px;
    }


    /* ---------------------------------------------------------
       Drawer
       --------------------------------------------------------- */

    .rt-megamenu--mobile .rt-megamenu__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100dvh;
        min-width: 0;

        background: #fff;
        border: 0;
        border-radius: 0;
        box-shadow: none;

        z-index: 999999;

        overflow: hidden;

        animation: rtmm-mobile-slide-in .25s ease;
    }

    .rt-megamenu--mobile .rt-megamenu__panel[hidden] {
        display: none;
    }

    @keyframes rtmm-mobile-slide-in {
        from {
            opacity: 0;
            transform: translateX(20px);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }


    /* ---------------------------------------------------------
       Encabezado del drawer
       --------------------------------------------------------- */

    .rt-megamenu__mobile-header {
        min-height: 64px;
        padding: 10px 16px;

        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;

        border-bottom: 1px solid var(--rtmm-border);

        background: #fff;

        position: sticky;
        top: 0;
        z-index: 5;
    }

    .rt-megamenu__mobile-title {
        grid-column: 2;

        font-size: 17px;
        font-weight: 700;
        color: var(--rtmm-text);

        text-align: center;
    }

    .rt-megamenu__mobile-close {
        grid-column: 3;

        justify-self: end;

        width: 44px;
        height: 44px;

        display: flex;
        align-items: center;
        justify-content: center;

        padding: 0;

        border: 0;
        background: transparent;

        color: var(--rtmm-text);

        font-size: 32px;
        line-height: 1;

        cursor: pointer;
    }

    .rt-megamenu__mobile-back {
        grid-column: 1;

        justify-self: start;

        display: inline-flex;
        align-items: center;
        gap: 6px;

        min-height: 44px;

        padding: 0;

        border: 0;
        background: transparent;

        color: var(--rtmm-primary);

        font-size: 14px;
        font-weight: 600;

        cursor: pointer;
    }

    .rt-megamenu__mobile-back[hidden] {
        display: none;
    }


    /* ---------------------------------------------------------
       Contenido
       --------------------------------------------------------- */

    .rt-megamenu--mobile .rt-megamenu__inner {
        display: block;

        height: calc(100dvh - 64px);

        min-height: 0;

        overflow-y: auto;
        overscroll-behavior: contain;

        background: #fff;
    }


    /* ---------------------------------------------------------
       Vista 1: categorías raíz
       --------------------------------------------------------- */

    .rt-megamenu--mobile .rt-megamenu__roots {
        display: block;

        margin: 0;
        padding: 8px 0;

        background: #fff;

        border: 0;
        border-radius: 0;
    }

    .rt-megamenu--mobile .rt-megamenu__root-item {
        margin: 0;
    }

    .rt-megamenu--mobile .rt-megamenu__root-link {
        min-height: 52px;

        padding: 12px 20px;

        font-size: 15px;
        font-weight: 500;

        border-bottom: 1px solid var(--rtmm-border);

        background: #fff;
    }

    .rt-megamenu--mobile .rt-megamenu__root-item.is-active .rt-megamenu__root-link {
        border-left: 0;

        padding-left: 20px;

        background: #fff;

        color: var(--rtmm-text) !important;

        font-weight: 500;
    }

    .rt-megamenu--mobile .rt-megamenu__root-link:hover {
        background: var(--rtmm-active-bg);
        color: var(--rtmm-primary) !important;
    }

    .rt-megamenu--mobile .rt-megamenu__chevron {
        width: 18px;
        height: 18px;
    }


    /* ---------------------------------------------------------
       Vista 2: hijos
       --------------------------------------------------------- */

    .rt-megamenu--mobile .rt-megamenu__children-wrap {
        display: none;

        padding: 16px 20px 32px;

        max-height: none;

        overflow: visible;
    }

    .rt-megamenu--mobile.is-showing-children .rt-megamenu__roots {
        display: none;
    }

    .rt-megamenu--mobile.is-showing-children .rt-megamenu__children-wrap {
        display: block;
    }

    .rt-megamenu--mobile .rt-megamenu__children {
        display: none;

        grid-template-columns: 1fr;

        gap: 22px;

        align-content: start;
    }

    .rt-megamenu--mobile .rt-megamenu__children.is-active {
        display: grid;
    }

    .rt-megamenu--mobile .rt-megamenu__group {
        min-width: 0;
    }

    .rt-megamenu--mobile .rt-megamenu__group-title {
        display: block;

        margin: 0 0 6px;

        padding: 0 0 8px;

        font-size: 13px;
        font-weight: 700;

        white-space: normal;
        overflow: visible;

        border-bottom: 2px solid var(--rtmm-primary);
    }

    .rt-megamenu--mobile .rt-megamenu__group-items a {
        min-height: 42px;

        display: flex;
        align-items: center;

        padding: 8px 0;

        font-size: 14px;

        white-space: normal;
        overflow: visible;
        text-overflow: unset;

        border-bottom: 1px solid #f0f0f0;
    }


    /* ---------------------------------------------------------
       Populares
       --------------------------------------------------------- */

    .rt-megamenu--mobile .rt-megamenu__popular {
        display: none;
    }


    /* ---------------------------------------------------------
       Bloqueo de scroll del documento
       --------------------------------------------------------- */

    body.rtmm-mobile-open {
        overflow: hidden;
    }

    .rt-megamenu--mobile .rt-megamenu__mobile-header {
        position: sticky !important;
        top: 0 !important;

        width: 100%;

        min-height: 64px;

        display: flex !important;
        align-items: center;
        justify-content: space-between;

        padding: 8px 16px;

        background: #ffffff;

        border-bottom: 1px solid #e5e7eb;

        z-index: 100;

        box-sizing: border-box;
    }


    /* Título Categorías */

    .rt-megamenu--mobile .rt-megamenu__mobile-title {
        display: block;

        color: #0d2b55;

        font-size: 18px;
        font-weight: 700;

        line-height: 1.2;
    }


    /* Botón cerrar */

    .rt-megamenu--mobile .rt-megamenu__mobile-close {
        width: 44px;
        height: 44px;

        display: flex !important;
        align-items: center;
        justify-content: center;

        flex: 0 0 44px;

        margin: 0;
        padding: 0;

        border: 0;
        border-radius: 50%;

        background: transparent;

        color: #00b4a0;

        font-family: inherit;
        font-size: 34px;
        font-weight: 300;
        line-height: 1;

        cursor: pointer;
    }


    /* Botón volver */

    .rt-megamenu--mobile .rt-megamenu__mobile-back {
        min-height: 44px;

        display: flex;
        align-items: center;
        gap: 8px;

        margin: 0;
        padding: 0;

        border: 0;
        background: transparent;

        color: #00b4a0;

        font-family: inherit;
        font-size: 15px;
        font-weight: 600;

        cursor: pointer;
    }


    /* Respetamos el atributo hidden */
    .rt-megamenu--mobile .rt-megamenu__mobile-back[hidden] {
        display: none !important;
    }


    /* Cuando estamos viendo subcategorías,
       quitamos el título central porque ya aparece "← Categorías" */

    .rt-megamenu--mobile.is-showing-children
    .rt-megamenu__mobile-title {
        display: none;
    }


    /* Panel completo */

    .rt-megamenu--mobile .rt-megamenu__panel {
        z-index: 999999 !important;
    }

    /* =====================================================
       CUANDO EL MEGA MENÚ ESTÁ ABIERTO
       ocultamos los controles del header normal
       ===================================================== */

    body.rtmm-mobile-open
    .rodio-header-responsive
    .rodio-mobile-logo {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.rtmm-mobile-open
    .rodio-header-responsive
    .rodio-mobile-actions {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.rtmm-mobile-open
    .rodio-mobile-search-row {
        display: none !important;
    }


    /* El mega menú debe cubrir completamente la pantalla */
    body.rtmm-mobile-open
    .rt-megamenu--mobile
    .rt-megamenu__panel {
        position: fixed !important;

        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;

        margin: 0 !important;

        background: #fff !important;

        z-index: 2147483000 !important;
    }


    /* Header propio del mega menú */
    body.rtmm-mobile-open
    .rt-megamenu--mobile
    .rt-megamenu__mobile-header {
        position: sticky !important;
        top: 0 !important;

        width: 100% !important;
        min-height: 64px;

        padding: 8px 20px;

        background: #fff !important;

        border-bottom: 1px solid #e5e7eb;

        z-index: 10;
    }
}
