/* =========================================================
   NAVEGACIÓN SUPERIOR

   Hoja única del menú público y del desplegable de cuenta. Sustituye a los
   bloques de nav que había en style.css y a css/responsive/navbar.css +
   navbar_index.css, que eran el mismo archivo repetido cambiando .nav por
   .nav-index. Es autosuficiente a propósito: el checkout la carga sin
   style.css.

   .nav        cabecera normal, sobre fondo blanco
   .nav-index  cabecera de la portada, sobre la foto
========================================================= */

.nav,
.nav-index {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 26px;
    box-sizing: border-box;
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    padding: 28px 24px 20px;
    background-color: transparent;
}

.nav li,
.nav-index li {
    list-style: none;
}

.nav_icon {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.logo {
    width: 220px;
    height: auto;
}

/* =========================
   ENTRADAS
========================= */

.nav-div-a {
    display: flex;
    align-items: center;
    gap: 26px;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
}

.nav-div-a-text,
.nav-index-div-a-text {
    display: inline-block;
    margin: 0;
    padding: 3px 6px;
    border: 0;
    background: transparent;
    color: rgb(0, 0, 0);
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

.nav-index-div-a-text {
    color: rgb(255, 255, 255);
    /* La portada va sobre foto: la sombra mantiene legible el texto */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 2px 6px rgba(0, 0, 0, 0.7);
}

.nav-div-a-text:hover,
.nav-div-a-text.is-active {
    color: rgb(0, 0, 0);
    box-shadow: inset 0 -2px 0 #2295bc;
}

.nav-index-div-a-text:hover,
.nav-index-div-a-text.is-active {
    color: #ffffff;
    box-shadow: inset 0 -2px 0 #2295bc;
}

/* =========================
   BOTÓN DE ACCESO
========================= */

.nav-access-button {
    width: auto;
    min-width: 88px;
    padding: 9px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #159ecc;
    border-radius: 999px;
    background: #123b54;
    box-shadow: 0 8px 18px rgba(18, 59, 84, 0.14);
    color: #ffffff;
    line-height: 1;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.nav-access-button:hover {
    padding: 9px 16px;
    border-color: #159ecc;
    background: #159ecc;
    box-shadow: 0 10px 24px rgba(21, 158, 204, 0.24);
    color: #ffffff;
    transform: translateY(-1px);
}

.nav-index-access-button {
    border-color: rgba(255, 255, 255, 0.72);
    background: rgba(12, 43, 62, 0.74);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-shadow: none;
}

/* =========================
   DESPLEGABLES
========================= */

.nav_desplegable {
    position: relative;
}

.nav_desplegable-toggle {
    padding-right: 18px;
}

.nav_desplegable-toggle::after {
    content: "▼";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #39b3f9;
    transition: transform 0.3s ease;
}

.nav_desplegable:hover .nav_desplegable-toggle::after,
.nav_desplegable-toggle[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}

.nav_submenu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 232px;
    margin: 0;
    padding: 12px 0;
    border-radius: 12px;
    background: rgba(11, 103, 143, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    list-style: none;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* :hover para ratón, .active para pantallas táctiles */
.nav_desplegable:hover .nav_submenu,
.nav_submenu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Salva el hueco entre la entrada y el desplegable: sin esto el menú se
   cierra al mover el ratón hacia él. */
.nav_submenu::before {
    content: "";
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    height: 14px;
}

.nav_submenu li a {
    display: block;
    padding: 10px 20px;
    color: #ffffff;
    font-family: "Raleway", Sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s ease;
}

.nav_submenu li a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

/* =========================
   CUENTA (avatar + desplegable)
   Sustituye al botón de acceso cuando hay sesión abierta. El panel de
   administración usa estas mismas clases.
========================= */

.nav-account {
    position: relative;
    display: inline-flex;
}

.nav-account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 14px 5px 5px;
    border: 1px solid #159ecc;
    border-radius: 999px;
    background: #123b54;
    box-shadow: 0 8px 18px rgba(18, 59, 84, 0.14);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.nav-account-trigger:hover,
.nav-account.is-open .nav-account-trigger {
    background: #159ecc;
    box-shadow: 0 10px 24px rgba(21, 158, 204, 0.24);
    transform: translateY(-1px);
}

.nav-account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    overflow: hidden;
    border-radius: 50%;
    background: #dff5fc;
    color: #123352;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.nav-account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nav-account-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

/* El panel muestra además el rol bajo el nombre */
.nav-account-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 160px;
    overflow: hidden;
    text-align: left;
}

.nav-account-identity strong {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-account-identity small {
    color: rgba(255, 255, 255, 0.76);
    font-size: 11px;
}

.nav-account-caret {
    width: 0;
    height: 0;
    border-top: 5px solid currentColor;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    transition: transform 160ms ease;
}

.nav-account.is-open .nav-account-caret {
    transform: rotate(180deg);
}

.nav-account-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 8px;
    border: 1px solid #dce6ec;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(18, 51, 82, 0.18);
}

/* `display: flex` gana al `[hidden]` del navegador, así que se repite aquí:
   sin esta regla el desplegable se vería siempre abierto. */
.nav-account-menu[hidden] {
    display: none;
}

.nav-account-menu form {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.nav-account-item {
    padding: 10px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #152536;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.nav-account-item:hover,
.nav-account-item:focus-visible {
    background: #dff5fc;
    color: #123352;
}

.nav-account-logout {
    margin-top: 4px;
    border-top: 1px solid #dce6ec;
    border-radius: 0 0 9px 9px;
    color: #b83f4d;
}

.nav-account-logout:hover,
.nav-account-logout:focus-visible {
    background: #fdebed;
    color: #b83f4d;
}

/* =========================
   HAMBURGUESA
========================= */

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 3000;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background: #39b3f9;
    transition: 0.3s;
}

/* =========================================================
   PANEL LATERAL

   A partir de aquí el menú colapsa. El corte está en 1100 px: con cinco
   entradas caben holgadas por encima, y colapsan antes de empezar a
   comprimirse. Los dos grupos quedan desplegados dentro del panel, para que
   ningún destino exija un segundo toque.
========================================================= */

@media (max-width: 1100px) {
    .hamburger {
        display: flex;
    }

    .nav,
    .nav-index {
        padding: 22px 20px 18px;
    }

    .logo {
        width: 165px;
    }

    .nav-div-a {
        position: fixed;
        top: 0;
        right: -78%;
        z-index: 1500;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 22px;
        width: 78%;
        max-width: 360px;
        height: 100vh;
        padding: 96px 28px 40px;
        overflow-y: auto;
        background: #123352;
        white-space: normal;
        transition: right 0.4s ease;
    }

    .nav.active .nav-div-a,
    .nav-index.active .nav-div-a {
        right: 0;
    }

    .nav.active .hamburger span:nth-child(1),
    .nav-index.active .hamburger span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav.active .hamburger span:nth-child(2),
    .nav-index.active .hamburger span:nth-child(2) {
        opacity: 0;
    }

    .nav.active .hamburger span:nth-child(3),
    .nav-index.active .hamburger span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    .nav::before,
    .nav-index::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: 0.3s;
    }

    .nav.active::before,
    .nav-index.active::before {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-open {
        overflow: hidden;
    }

    .nav-div-a > li {
        width: 100%;
    }

    .nav-div-a-text,
    .nav-index-div-a-text {
        color: #ffffff;
        font-size: 15px;
        text-shadow: none;
    }

    .nav-div-a-text:hover,
    .nav-index-div-a-text:hover {
        color: #39b3f9;
        box-shadow: none;
    }

    /* Los grupos van abiertos: el rótulo pasa a ser el título de la sección */
    .nav_desplegable-toggle {
        padding-right: 6px;
        color: rgba(255, 255, 255, 0.62);
        font-size: 12px;
        letter-spacing: 0.08em;
        cursor: default;
    }

    .nav_desplegable-toggle::after {
        content: none;
    }

    .nav_submenu {
        position: static;
        min-width: 0;
        margin-top: 10px;
        padding: 0;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .nav_submenu::before {
        content: none;
    }

    .nav_submenu li a {
        padding: 9px 0 9px 14px;
        border-left: 2px solid rgba(255, 255, 255, 0.18);
        font-size: 15px;
    }

    .nav_submenu li a:hover {
        border-left-color: #39b3f9;
        background: transparent;
        color: #39b3f9;
    }

    /* Acceso —o el avatar, si hay sesión— arriba del panel */
    .nav-access {
        order: -1;
        margin-bottom: 6px;
    }

    .nav-account-menu {
        right: auto;
        left: 0;
    }

    .nav-account-name,
    .nav-account-identity {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .logo {
        width: 140px;
    }

    .nav-div-a {
        right: -88%;
        width: 88%;
    }
}
