/* --- 1. RESET Y ESTRUCTURA BASE --- */
.bdm-wrapper {
    position: relative;
    width: 100%;
    font-family: inherit;
    box-sizing: border-box;
    --bdm-color-primary: var(--e-global-color-primary, #1C34C7);
    --bdm-color-secondary: var(--e-global-color-secondary, #FF8383);
    --bdm-color-text: var(--e-global-color-text, #1E293B);
    --bdm-color-accent: var(--e-global-color-accent, #FBF8FF);
    --bdm-color-border: var(--e-global-color-095792b, #F1F5F9);
    --bdm-color-dark: var(--e-global-color-b150d3d, #1D1A27);
    --bdm-color-primary-dark: var(--e-global-color-5bf98bb, #1B33A8);
    --bdm-color-surface: #fff;
    background-color: var(--bdm-color-surface);
    overflow: hidden;
}

.bdm-wrapper .bdm-viewport {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 50px;
    background-color: var(--bdm-color-surface);
}

.bdm-wrapper .bdm-nav-container {
    position: relative;
    width: 100%;
    background-color: var(--bdm-color-surface);
    transition: height 0.3s ease;
}

.bdm-wrapper ul.bdm-root,
.bdm-wrapper ul.bdm-sub-menu {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

/* --- 2. POSICIONAMIENTO "OVERLAY" --- */

.bdm-wrapper ul.bdm-root {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.3s, visibility 0.3s;
}

.bdm-wrapper ul.bdm-sub-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--bdm-color-surface);
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.3s, visibility 0.3s;
    z-index: 20;
}

/* --- 3. ESTADOS DE ANIMACIÓN --- */

.bdm-wrapper ul.bdm-sub-menu.is-active {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto !important;
}

/* El estado "pushed" debe estar declarado después para sobreescribir is-active */
.bdm-wrapper ul.bdm-root.is-pushed-left,
.bdm-wrapper ul.bdm-sub-menu.is-pushed-left {
    position: absolute;
    pointer-events: none !important;
}

/* Ocultar elementos directamente sin afectar los submenús activos anidados */
.bdm-wrapper ul.bdm-root.is-pushed-left > li > *:not(.bdm-sub-menu),
.bdm-wrapper ul.bdm-sub-menu.is-pushed-left > li > *:not(.bdm-sub-menu) {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Remover fondos y bordes de los niveles anteriores para que no se superpongan */
.bdm-wrapper ul.bdm-root.is-pushed-left > li,
.bdm-wrapper ul.bdm-sub-menu.is-pushed-left > li {
    background-color: transparent !important;
    border-color: transparent !important;
}

.bdm-wrapper ul.bdm-sub-menu.bdm-mega-menu {
    display: flex;
    flex-direction: column;
}

.bdm-wrapper li.bdm-mega-content {
    padding: 20px;
    background-color: var(--bdm-color-surface);
    flex: 0 0 auto;
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
}

.bdm-wrapper .bdm-mega-inner {
    width: 100%;
    box-sizing: border-box;
}

/* --- 4. DISEÑO DE ITEMS --- */

.bdm-wrapper li.bdm-item-row {
    position: static;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bdm-color-border);
    background-color: var(--bdm-color-surface);
}

.bdm-wrapper .bdm-link {
    flex-grow: 1;
    text-decoration: none;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    color: var(--bdm-color-text);
    font-size: 16px;
    font-weight: 500;
}

.bdm-wrapper li.bdm-item-row:hover {
    background-color: var(--bdm-color-accent);
}

/* --- 5. BOTONES Y FLECHAS --- */

.bdm-wrapper button.bdm-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 18px;
    height: auto;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: none;
    color: var(--bdm-color-primary);
    flex-shrink: 0;
}

.bdm-wrapper .bdm-arrow {
    display: block;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
}

.bdm-wrapper li.bdm-back-item {
    background-color: transparent;
    border-bottom: none;
    flex-shrink: 0;
}

.bdm-wrapper .bdm-parent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background-color: var(--bdm-color-accent);
    border-bottom: 1px solid var(--bdm-color-border);
    font-size: 14px;
    color: var(--bdm-color-text);
    flex-shrink: 0;
}

.bdm-wrapper .bdm-view-all {
    text-decoration: none;
    font-weight: 600;
    color: var(--bdm-color-primary);
}

.bdm-wrapper .bdm-back-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 20px;
    margin: 0 0 10px;
    cursor: pointer;
    color: var(--bdm-color-primary);
    font-size: 14px;
    background-color: var(--bdm-color-surface);
    border: 1px solid var(--bdm-color-primary);
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
    box-sizing: border-box;
}

.bdm-wrapper .bdm-back-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: inherit;
}

.bdm-wrapper .bdm-back-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.bdm-wrapper .bdm-menu-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    margin-right: 12px;
    vertical-align: middle;
    display: inline-block;
    flex-shrink: 0;
}