/**
 * NUEVO MENÚ DE NAVEGACIÓN - KAI CHILD THEME
 * Diseño profesional con estructura:
 * - Zona Izquierda: Logo
 * - Zona Central: Navegación (Para Financieras, Para Gestores)
 * - Zona Derecha: Selector País/Idioma + CTA's
 */

/* ========================================================================
   HEADER PRINCIPAL
   ======================================================================== */

.kai-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.kai-header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    gap: 2rem;
}

/* ========================================================================
   ZONA IZQUIERDA - LOGO
   ======================================================================== */

.kai-header-logo {
    flex-shrink: 0;
}

.kai-header-logo img {
    height: 40px;
    width: auto;
    transition: opacity 0.2s ease;
}

.kai-header-logo:hover img {
    opacity: 0.8;
}

/* ========================================================================
   ZONA CENTRAL - NAVEGACIÓN PRINCIPAL
   ======================================================================== */

.kai-header-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.kai-nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kai-nav-item {
    position: relative;
}

.kai-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-family: "Ubuntu", sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #003449;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.kai-nav-link:hover {
    color: #00C776 !important;
    background-color: #f9fafb;
}

.kai-nav-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.kai-nav-item:hover .kai-nav-link svg {
    transform: rotate(180deg);
}

/* ========================================================================
   DROPDOWNS (MEGA MENÚS)
   ======================================================================== */

.kai-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 2rem;
    min-width: 800px;
    margin-top: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

.kai-nav-item:hover .kai-dropdown {
    opacity: 1;
    visibility: visible;
    margin-top: 0.5rem;
}

.kai-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
}

/* Dropdown de una sola columna (Para Gestores) */
.kai-dropdown-single {
    min-width: 400px;
    padding: 1.5rem;
}

.kai-dropdown-single .kai-dropdown-section {
    margin: 0;
}

.kai-dropdown-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kai-dropdown-section-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
}

.kai-dropdown-section-title {
    font-size: 20px;
    font-weight: 700;
    color: #003449;
    margin: 0 0 1rem 0;
}

.kai-dropdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.kai-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.kai-dropdown-item:hover {
    background-color: #f0fdf4;
    transform: translateX(4px);
}

.kai-dropdown-item-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
    color: #374151 !important;
    font-size: 15px;
    font-weight: 500;
    width: 100%;
}

.kai-dropdown-item:hover .kai-dropdown-item-link {
    color: #00C776 !important;
}

.kai-dropdown-item-arrow {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.kai-dropdown-item:hover .kai-dropdown-item-arrow {
    opacity: 1;
}

/* ========================================================================
   ZONA DERECHA - UTILIDADES Y CTA'S
   ======================================================================== */

.kai-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* ========================================================================
   SELECTOR PAÍS/IDIOMA COMPACTO
   ======================================================================== */

.kai-locale-selector {
    position: relative;
    display: flex;
    align-items: center;
}

.kai-locale-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: "Ubuntu", sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.kai-locale-button:hover {
    border-color: #00C776;
    background-color: #ffffff;
}

.kai-locale-icon {
    width: 20px;
    height: 20px;
}

.kai-locale-current {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kai-locale-flag {
    font-size: 18px;
}

.kai-locale-code {
    font-weight: 700;
    color: #003449;
}

.kai-locale-separator {
    color: #d1d5db;
}

.kai-locale-lang {
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
}

/* Dropdown del selector */
.kai-locale-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    min-width: 400px;
    margin-top: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.kai-locale-selector:hover .kai-locale-dropdown {
    opacity: 1;
    visibility: visible;
}

.kai-locale-dropdown-section {
    margin-bottom: 0;
}

.kai-locale-dropdown-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.kai-locale-dropdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kai-locale-dropdown-item,
a.kai-locale-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    text-decoration: none !important;
    color: inherit;
}

.kai-locale-dropdown-item:hover,
a.kai-locale-dropdown-item:hover {
    background-color: #f0fdf4;
}

.kai-locale-dropdown-item.active {
    background-color: #d1fae5;
    border-color: #00C776;
}

.kai-locale-dropdown-item-flag {
    font-size: 20px;
}

.kai-locale-dropdown-item-info {
    flex: 1;
}

.kai-locale-dropdown-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #003449;
}

.kai-locale-dropdown-item-code {
    font-size: 12px;
    color: #6b7280;
}

.kai-locale-dropdown-item-check {
    color: #00C776;
    font-size: 18px;
    opacity: 0;
}

.kai-locale-dropdown-item.active .kai-locale-dropdown-item-check {
    opacity: 1;
}

/* ========================================================================
   BOTONES DE ACCIÓN
   ======================================================================== */

.kai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: "Ubuntu", sans-serif;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.kai-btn-secondary {
    background: transparent;
    color: #003449 !important;
    border: 2px solid #e5e7eb;
}

.kai-btn-secondary:hover {
    border-color: #003449;
    background-color: #f9fafb;
}

.kai-btn-primary {
    background: #00C776;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 199, 118, 0.2);
}

.kai-btn-primary:hover {
    background: #00a060;
    box-shadow: 0 4px 12px rgba(0, 199, 118, 0.3);
    transform: translateY(-1px);
}

/* ========================================================================
   MENÚ MÓVIL
   ======================================================================== */

.kai-mobile-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    position: relative;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.kai-mobile-toggle-icon {
    width: 28px;
    height: 28px;
    color: #003449;
    pointer-events: none;
}

/* Añadir rotación para SVG en acordeones */
.kai-mobile-nav-link svg {
    transition: transform 0.3s ease;
}

.kai-mobile-subnav.active+.kai-mobile-nav-link svg,
.kai-mobile-nav-item:has(.kai-mobile-subnav.active)>.kai-mobile-nav-link svg {
    transform: rotate(180deg);
}

/* IMPORTANTE: El menú offcanvas solo se muestra en móvil/tablet */
@media (min-width: 1025px) {

    .kai-offcanvas,
    .kai-offcanvas-overlay,
    .kai-mobile-toggle {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .kai-header-nav {
        display: none;
    }

    .kai-header-actions .kai-btn {
        display: none;
    }

    .kai-header-actions .kai-locale-selector {
        display: none;
    }

    .kai-mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .kai-header-container {
        padding: 0.75rem 1rem;
        gap: 1rem;
    }

    .kai-header-logo img {
        height: 35px;
    }
}

/* ========================================================================
   OFFCANVAS MÓVIL
   ======================================================================== */

.kai-offcanvas {
    position: fixed;
    top: 0;
    right: -100%;
    width: 90%;
    max-width: 400px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Bootstrap Breakpoints: aprovechamos el sistema estándar */
/* xs: <576px - Móviles pequeños */
/* sm: ≥576px - Móviles grandes */
/* md: ≥768px - Tablets */
/* lg: ≥992px - Tablets grandes / Laptops pequeñas */
/* xl: ≥1200px - Desktop */

/* Móviles pequeños (xs) */
@media (max-width: 575.98px) {
    .kai-offcanvas {
        width: 90%;
        max-width: none;
    }
}

/* Móviles grandes (sm) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .kai-offcanvas {
        width: 85%;
        max-width: 400px;
    }
}

/* Tablets (md) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .kai-offcanvas {
        width: 60%;
        max-width: 500px;
    }
}

/* Tablets grandes / Laptops (lg) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .kai-offcanvas {
        width: 45%;
        max-width: 450px;
    }
}

.kai-offcanvas.active {
    right: 0;
}

.kai-offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.kai-offcanvas-overlay.active {
    opacity: 1;
    visibility: visible;
}

.kai-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
}

.kai-offcanvas-title {
    font-size: 18px;
    font-weight: 700;
    color: #003449;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.kai-offcanvas-close {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kai-offcanvas-close:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.kai-offcanvas-close svg {
    width: 20px;
    height: 20px;
    color: #374151;
}

.kai-offcanvas-body {
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* Asegurar que todo el contenido se adapte al contenedor */
.kai-offcanvas-body>* {
    max-width: 100%;
    box-sizing: border-box;
}

.kai-mobile-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.kai-mobile-nav-item {
    margin-bottom: 0;
}

.kai-mobile-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: #f9fafb;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    color: #003449 !important;
    text-decoration: none !important;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    width: 100%;
    box-sizing: border-box;
}

.kai-mobile-nav-link:hover,
.kai-mobile-nav-link:active {
    background: #f0fdf4;
    color: #00C776 !important;
    border-color: #d1fae5;
}

.kai-mobile-nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.kai-mobile-subnav {
    list-style: none;
    padding: 0.5rem 0 0 0;
    margin: 0;
    display: none;
    animation: slideDown 0.3s ease;
}

.kai-mobile-subnav.active {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kai-mobile-subnav-item {
    margin-bottom: 0;
}

.kai-mobile-subnav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0.75rem 1.5rem;
    color: #6b7280 !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.kai-mobile-subnav-link:hover,
.kai-mobile-subnav-link:active {
    color: #00C776 !important;
    background-color: #f9fafb;
    border-left-color: #00C776;
    padding-left: 1.75rem;
}

.kai-mobile-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.kai-mobile-actions .kai-btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
}

.kai-mobile-locale {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
}

.kai-mobile-locale .kai-locale-dropdown-section {
    margin-bottom: 1rem;
}

.kai-mobile-locale .kai-locale-dropdown-section:last-child {
    margin-bottom: 0;
}

.kai-mobile-locale .kai-locale-dropdown-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.kai-mobile-locale .kai-locale-dropdown-list {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}

.kai-mobile-locale .kai-locale-dropdown-item,
.kai-mobile-locale a.kai-locale-dropdown-item {
    flex: 1 1 calc(33.333% - 0.5rem);
    /* 3 items por fila con gap */
    min-width: 0;
    max-width: 100%;
    padding: 0.625rem 0.5rem;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    text-decoration: none !important;
    color: inherit;
}

.kai-mobile-locale .kai-locale-dropdown-item.active,
.kai-mobile-locale a.kai-locale-dropdown-item.active {
    background: #d1fae5;
    border-color: #00C776;
}

.kai-mobile-locale .kai-locale-dropdown-item-flag {
    font-size: 18px;
}

.kai-mobile-locale .kai-locale-dropdown-item-info {
    flex: 1;
    min-width: 0;
}

.kai-mobile-locale .kai-locale-dropdown-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #003449;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.kai-mobile-locale .kai-locale-dropdown-item-check {
    font-size: 14px;
}

/* ========================================================================
   ANIMACIONES Y TRANSICIONES
   ======================================================================== */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.kai-dropdown {
    animation: fadeInDown 0.3s ease;
}

/* ========================================================================
   RESPONSIVE ADJUSTMENTS
   ======================================================================== */

@media (max-width: 1200px) {
    .kai-dropdown {
        min-width: 600px;
    }

    .kai-dropdown-grid {
        gap: 2rem;
    }
}

/* Ajustes de espaciado siguiendo breakpoints de Bootstrap */

/* sm: Móviles grandes (≥576px) */
@media (min-width: 576px) {
    .kai-offcanvas-body {
        padding: 1.25rem;
    }

    .kai-mobile-nav-link {
        padding: 0.875rem 1rem;
        font-size: 15px;
    }
}

/* md: Tablets (≥768px) */
@media (min-width: 768px) {
    .kai-offcanvas-header {
        padding: 1.5rem 1.25rem;
    }

    .kai-offcanvas-body {
        padding: 1.5rem 1.25rem;
    }

    .kai-offcanvas-title {
        font-size: 20px;
    }

    .kai-mobile-nav-link {
        padding: 1rem 1.25rem;
        font-size: 16px;
    }

    .kai-mobile-subnav-link {
        font-size: 15px;
    }
}

/* lg: Tablets grandes / Laptops (≥992px) */
@media (min-width: 992px) {
    .kai-offcanvas-body {
        padding: 1.75rem 1.5rem;
    }

    .kai-mobile-nav-link {
        padding: 1.125rem 1.5rem;
        font-size: 16px;
    }
}

/* ========================================================================
   PANTALLAS MUY PEQUEÑAS - SOLO BANDERAS
   ======================================================================== */

/* Para pantallas muy pequeñas (menos de 360px) - Solo banderas en desktop */
@media (max-width: 359px) {
    .kai-locale-dropdown {
        min-width: 200px;
        /* Reducir ancho del dropdown */
        padding: 0.75rem;
    }

    .kai-locale-dropdown-item-info,
    .kai-locale-dropdown-item-name,
    .kai-locale-dropdown-item-code {
        display: none !important;
        /* Ocultar texto, solo mostrar banderas */
    }

    .kai-locale-dropdown-item,
    a.kai-locale-dropdown-item {
        justify-content: center;
        /* Centrar solo la bandera */
        padding: 0.75rem;
        min-height: 48px;
        /* Mantener altura táctil */
    }

    .kai-locale-dropdown-item-flag {
        font-size: 24px;
        /* Hacer banderas más grandes */
    }

    .kai-locale-dropdown-item-check {
        display: block !important;
        /* Mantener check visible */
        font-size: 20px;
    }
}

/* Para pantallas pequeñas (360px - 480px) - Solo banderas en móvil */
@media (max-width: 480px) {

    .kai-mobile-locale .kai-locale-dropdown-item-info,
    .kai-mobile-locale .kai-locale-dropdown-item-name {
        display: none !important;
        /* Ocultar texto en móvil */
    }

    .kai-mobile-locale .kai-locale-dropdown-item,
    .kai-mobile-locale a.kai-locale-dropdown-item {
        justify-content: center;
        /* Centrar solo la bandera */
        padding: 0.75rem 0.5rem;
        min-height: 48px;
    }

    .kai-mobile-locale .kai-locale-dropdown-item-flag {
        font-size: 22px;
        /* Banderas más grandes en móvil */
    }

    .kai-mobile-locale .kai-locale-dropdown-item-check {
        display: block !important;
        font-size: 18px;
    }

    /* Ajustar el grid para pantallas pequeñas */
    .kai-mobile-locale .kai-locale-dropdown-list {
        gap: 0.25rem;
    }

    .kai-mobile-locale .kai-locale-dropdown-item,
    .kai-mobile-locale a.kai-locale-dropdown-item {
        flex: 1 1 calc(50% - 0.25rem);
        /* 2 items por fila en pantallas pequeñas */
    }
}

/* Para pantallas extra pequeñas (menos de 320px) - Ajustes adicionales */
@media (max-width: 319px) {

    .kai-mobile-locale .kai-locale-dropdown-item,
    .kai-mobile-locale a.kai-locale-dropdown-item {
        flex: 1 1 calc(33.333% - 0.25rem);
        /* 3 items por fila */
        padding: 0.5rem 0.25rem;
    }

    .kai-mobile-locale .kai-locale-dropdown-item-flag {
        font-size: 20px;
    }

    .kai-mobile-locale .kai-locale-dropdown-item-check {
        font-size: 16px;
    }
}