/* ==========================================================================
   Botón de usuario en cabecera
   ========================================================================== */

/*
 * Este botón reemplaza al botón flotante lateral anterior.
 * El JavaScript lo inserta en la cabecera desktop y mobile de Astra.
 */

.boton-usuario-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 9px;
    line-height: 1;
}

/*
 * Estado base: usuario NO logueado.
 * Este es el botón "Iniciar sesión", por eso mantiene fondo naranja.
 */

.boton-usuario-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgb(242, 109, 0);
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.15;
    padding: 5px 10px;
    border: 1px solid rgb(242, 109, 0);
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: none;
}

.boton-usuario-header:hover,
.boton-usuario-header:focus,
.boton-usuario-header.activo {
    background-color: #005bb5;
    border-color: #005bb5;
    color: #ffffff;
    outline: none;
    text-decoration: none;
}

/*
 * Estado logueado: botón de usuario con icono + nombre + flecha.
 * Lo hacemos más delicado con fondo gris oscuro y borde naranja.
 */

body.logged-in .boton-usuario-header {
    background-color: #2b2b2b;
    color: #f5f5f5;
    padding: 5px 10px 5px 6px;
    border-color: rgb(242, 109, 0);
}

body.logged-in .boton-usuario-header:hover,
body.logged-in .boton-usuario-header:focus,
body.logged-in .boton-usuario-header.activo {
    background-color: #1f1f1f;
    border-color: rgb(242, 109, 0);
    color: #ffffff;
    outline: none;
    text-decoration: none;
    box-shadow: 0 0 0 2px rgba(242, 109, 0, 0.16);
}

.boton-usuario-header:focus-visible {
    outline: 2px solid rgba(242, 109, 0, 0.65);
    outline-offset: 2px;
}

.boton-usuario-header:active {
    transform: translateY(1px);
}

.boton-usuario-contenido {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
}

.boton-usuario-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    background-color: rgba(242, 109, 0, 0.14);
    color: rgb(242, 109, 0);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.boton-usuario-header:hover .boton-usuario-icono,
.boton-usuario-header:focus .boton-usuario-icono,
.boton-usuario-header.activo .boton-usuario-icono {
    color: #ffffff;
    background-color: rgb(242, 109, 0);
}

.boton-usuario-icono-svg {
    display: block;
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.boton-usuario-nombre {
    display: inline-block;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.boton-usuario-flecha {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    margin-left: 0;
    transform: translateY(-1px);
    color: rgba(255, 255, 255, 0.75);
}

/*
 * Compatibilidad defensiva:
 * Si por caché quedara el botón viejo con ID #boton-usuario,
 * lo ocultamos para evitar duplicados o el botón flotante lateral.
 */

#boton-usuario {
    display: none !important;
}

/*
 * Ajustes desktop
 */

.boton-usuario-wrapper-desktop {
    margin-left: 11px;
}

.ast-desktop-header .boton-usuario-wrapper {
    align-self: center;
}

/*
 * Ajustes mobile
 */

.boton-usuario-wrapper-mobile {
    margin-left: 6px;
    margin-right: 6px;
}

.boton-usuario-mobile {
    font-size: 12px;
    padding: 4px 8px;
}

body.logged-in .boton-usuario-mobile {
    padding: 4px 8px 4px 5px;
}

.boton-usuario-mobile .boton-usuario-icono {
    width: 19px;
    height: 19px;
    min-width: 19px;
}

.boton-usuario-mobile .boton-usuario-icono-svg {
    width: 11px;
    height: 11px;
}

.boton-usuario-mobile .boton-usuario-nombre {
    max-width: 82px;
}

.ast-mobile-header-wrap .boton-usuario-wrapper {
    align-self: center;
}

/*
 * En pantallas muy pequeñas, reducimos un poco el botón para evitar
 * que choque con el logo o con el menú hamburguesa.
 */

@media (max-width: 420px) {
    .boton-usuario-wrapper {
        margin-left: 5px;
        margin-right: 5px;
    }

    .boton-usuario-header {
        font-size: 11px;
        padding: 4px 7px;
    }

    body.logged-in .boton-usuario-header {
        padding: 4px 7px 4px 5px;
    }

    .boton-usuario-contenido {
        gap: 4px;
    }

    .boton-usuario-icono {
        width: 18px;
        height: 18px;
        min-width: 18px;
    }

    .boton-usuario-icono-svg {
        width: 10px;
        height: 10px;
    }

    .boton-usuario-nombre {
        max-width: 64px;
    }

    .boton-usuario-flecha {
        font-size: 9px;
    }
}

/* ==========================================================================
   Panel lateral de usuario
   ========================================================================== */

#barra-lateral {
    position: fixed;
    top: 0;
    right: -280px;
    height: 100%;
    width: 280px;
    max-width: 85vw;
    background-color: rgba(0, 0, 0, 0.9);
    color: #ffffff;
    z-index: 9998;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding-top: 100px;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.25);
}

#barra-lateral.abierta {
    right: 0;
}

#barra-lateral a {
    display: block;
    width: 100%;
    text-align: left;
    padding: 16px 24px;
    color: #ffffff;
    text-decoration: none;
    font-size: 16px;
    line-height: 1.3;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transition: background-color 0.2s ease, color 0.2s ease;
}

#barra-lateral a:last-child {
    border-bottom: none;
}

#barra-lateral a:hover,
#barra-lateral a:focus {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    outline: none;
    text-decoration: none;
}

/*
 * Ajuste mobile del panel lateral.
 */

@media (max-width: 544px) {
    #barra-lateral {
        width: 260px;
        max-width: 88vw;
        padding-top: 90px;
    }

    #barra-lateral a {
        font-size: 15px;
        padding: 15px 20px;
    }
}