/* ============================================
   CABECERA INSTITUCIONAL
============================================ */

.portal-header {
    background-color: #ffffff;
}

.portal-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 115px;

    padding-top: 22px;
    padding-bottom: 22px;

    gap: 32px;
}


/* LOGO CSIC */

.portal-header-brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.portal-logo {
    display: block;

    height: 65px;
    width: auto;

    max-width: 100%;
    object-fit: contain;
}


/* LOGO MINISTERIO */

.portal-ministry-link {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
}

.portal-ministry-logo {
    display: block;

    height: 65px;
    width: auto;

    max-width: 260px;
    object-fit: contain;
}


/* ============================================
   BARRA DE NAVEGACIÓN
============================================ */

.portal-navbar {
    background-color: #f0f1f3;
    padding-top: 0;
    padding-bottom: 0;
}

.portal-navbar .navbar-nav {
    align-items: stretch;
}


/* ============================================
   ENLACES DE NAVEGACIÓN
============================================ */

.portal-navbar :is(
    .portal-nav-link,
    .portal-user-link,
    .portal-login-link
) {
    position: relative;

    padding: 14px 16px !important;

    color: #252525 !important;
    font-size: 0.95rem;
    font-weight: 500;

    text-decoration: none;

    /* Sin sombreado de fondo */
    background-color: transparent !important;

    /* Transición del color del texto */
    transition: color 0.2s ease;
}


/* EFECTO HOVER */

.portal-navbar .portal-nav-link:hover,
.portal-navbar .portal-nav-link:focus-visible {

    color: #111111 !important;

    background-color: #e3e5e8;

}

/* ============================================
   EFECTO AL PASAR EL RATÓN
============================================ */

.portal-navbar :is(
    .portal-nav-link,
    .portal-user-link,
    .portal-login-link
):is(:hover, :focus-visible, .show) {

    /* Rojo oscuro del CSIC */
    color: #a30d1b !important;

    /* Mantener el fondo transparente */
    background-color: transparent !important;
}

/* ============================================
   SUBRAYADO ROJO ANIMADO
============================================ */

.portal-navbar :is(
    .portal-nav-link,
    .portal-user-link,
    .portal-login-link
)::before {

    content: "";

    position: absolute;

    bottom: 6px;
    left: 16px;
    right: 16px;

    height: 3px;

    background-color: #b20e1e;

    /* Inicialmente oculto */
    transform: scaleX(0);
    transform-origin: left center;

    transition: transform 0.25s ease;

    pointer-events: none;
}


/* Mostrar subrayado al pasar el ratón o abrir el desplegable */

.portal-navbar :is(
    .portal-nav-link,
    .portal-user-link,
    .portal-login-link
):is(:hover, :focus-visible, .show)::before {

    transform: scaleX(1);
}


/* ============================================
   DROPDOWN PRINCIPAL
============================================ */

.portal-dropdown {
    min-width: 350px;
    max-width: calc(100vw - 24px);

    padding: 6px 0;

    border: 1px solid #dee2e6;
    border-radius: 5px;

    background-color: #ffffff;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

.portal-dropdown .dropdown-item {
    padding: 10px 16px;
    font-size: 0.9rem;
    color: #252525;
    white-space: normal;
}

.portal-dropdown .dropdown-item:hover {
    background-color: #f1f3f5;
}

.portal-dropdown .dropdown-item:focus {
    background-color: #e9ecef;
    color: #212529;
}


/* ============================================
   REGISTRO DE ACCIONES
============================================ */

.portal-submenu-item {
    position: relative;
}

.portal-submenu-row {
    display: flex;
    align-items: stretch;
}

.portal-submenu-row:hover {
    background-color: #f1f3f5;
}


/* ENLACE AL REGISTRO */

.portal-submenu-row .portal-registro-link {
    display: flex;
    align-items: center;

    flex: 1;
    min-width: 0;
    width: auto;

    padding: 11px 16px;

    background: transparent;
}


/* FLECHA DEL SUBMENÚ */

.portal-submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0 16px;

    border: none;
    background: transparent;

    color: #495057;
    cursor: pointer;
}

/* Flecha del submenú */

.portal-submenu-toggle:hover {
    background-color: transparent;
    color: #212529;
}

/* Mantener visible el foco al navegar con teclado */

.portal-submenu-toggle:focus-visible {
    background-color: transparent;
    outline: 2px solid #b20e1e;
    outline-offset: -2px;
}

.portal-submenu-toggle i {
    font-size: 0.8rem;
}


/* ============================================
   SUBMENÚ LATERAL
============================================ */

.portal-submenu-panel {
    display: none;

    position: absolute;

    top: 0;
    left: calc(100% - 1px);

    z-index: 1060;

    min-width: 245px;

    margin: 0;
    padding: 6px 0;

    background-color: #ffffff;

    border: 1px solid #dee2e6;
    border-radius: 5px;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}


/* SUBMENÚ ABIERTO */

.portal-submenu-panel.is-open {
    display: block;
}


/* SOLO SI NO CABE A LA DERECHA */

.portal-submenu-panel.open-left {
    left: auto;
    right: calc(100% - 1px);
}


/* ENLACES DEL SUBMENÚ */

.portal-submenu-panel .dropdown-item {
    padding: 10px 16px;

    font-size: 0.9rem;
    white-space: nowrap;
}

.portal-submenu-panel .dropdown-item:hover {
    background-color: #f1f3f5;
}


/* ============================================
   FORMULARIOS NO DISPONIBLES
============================================ */

.portal-disabled {
    color: #868e96 !important;
    cursor: default;
}

.portal-disabled:hover {
    background-color: transparent !important;
}

.portal-soon {
    display: block;

    margin-left: 25px;

    font-size: 0.75rem;
    color: #868e96;
}


/* ============================================
   RESPONSIVE - TABLETS Y MÓVILES
============================================ */

@media (max-width: 991.98px) {

    /* CABECERA */

    .portal-header-inner {
        min-height: 90px;

        padding-top: 16px;
        padding-bottom: 16px;

        gap: 20px;
    }

    .portal-logo {
        height: 60px;
        max-width: 100%;
    }

    .portal-ministry-logo {
        height: 52px;
        max-width: 210px;
    }


    /* NAVBAR */

    .portal-navbar {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .portal-navbar .navbar-collapse {
        padding-top: 10px;
    }

    .portal-navbar .portal-nav-link {
        padding: 12px 8px !important;
    }

    /* Subrayado adaptado a móviles */

    .portal-navbar :is(
        .portal-nav-link,
        .portal-user-link,
        .portal-login-link
    )::before {

        left: 8px;
        right: auto;

        bottom: 6px;

        width: 65px;
        height: 2px;
    }


    /* MENÚ PRINCIPAL */

    .portal-dropdown {
        width: 100%;
        min-width: 0;
        max-width: none;

        box-shadow: none;
    }


    /* SUBMENÚ */

    .portal-submenu-panel,
    .portal-submenu-panel.open-left {

        position: static;

        width: 100%;
        min-width: 0;

        margin: 0;
        padding-left: 16px;

        border: none;
        border-radius: 0;

        box-shadow: none;

        background-color: #f8f9fa;
    }

    .portal-submenu-toggle i {
        transform: rotate(90deg);
    }

    .portal-navbar .portal-user-link,
    .portal-navbar .portal-login-link {
        padding: 12px 8px !important;
    }

}


/* ============================================
   MÓVILES PEQUEÑOS
============================================ */

@media (max-width: 575.98px) {

    .portal-header-inner {
        flex-wrap: wrap;
        justify-content: center;

        gap: 12px;

        padding-top: 15px;
        padding-bottom: 15px;
    }

    .portal-logo {
        height: auto;
        max-height: 58px;
        max-width: 90vw;
    }

    .portal-ministry-link {
        margin-left: 0;
    }

    .portal-ministry-logo {
        height: 45px;
        max-width: 200px;
    }

}