*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Nunito Sans", serif;
}

/* ===========================================================================
   HEADER — mobile-first
   ---------------------------------------------------------------------------
   Mobile (< 1024px):  [☰] [logo]  título…               [avatar]
   Desktop:            [logo] [★★★]      TÍTULO      [?] [avatar] Nombre
   El alto sale de --ax-header-h, que usan también el sidebar y el contenido,
   así los tres quedan alineados sin números mágicos repetidos.
   =========================================================================== */

:root {
    --ax-header-h: 52px;
    /* Alto real ocupado arriba: header + el notch en iPhone con viewport-fit. */
    --ax-top: calc(var(--ax-header-h) + env(safe-area-inset-top, 0px));
}

.header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #4E4E4E;
    color: white;
    padding: env(safe-area-inset-top, 0px) 12px 0;
    position: fixed;
    top: 0;
    /* left/right en vez de width:100vw. `100vw` incluye el ancho de la barra de
       scroll, y como <html> reserva ese hueco siempre (scrollbar-gutter: stable
       en styles.css), el header se pasaba a la derecha y aparecía scroll
       horizontal en todas las vistas. */
    left: 0;
    right: 0;
    height: var(--ax-top);
    z-index: 1000;
}

.header-burger {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-left: -6px;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.header-burger:hover,
.header-burger[aria-expanded="true"] { background: rgba(255, 255, 255, .12); }
.header-burger:focus-visible { outline: 2px solid #91bcf5; outline-offset: 2px; }

.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo1 {
    width: 84px;
    display: block;
}

/* En mobile el título va en el flujo, al lado del logo, y se corta con "…"
   si no entra. Así nunca pisa al avatar ni al logo. */
.title-header {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

/* Con el contenedor adelante: `.fa-regular` de Font Awesome se carga después
   y fija su propio display, que pisaba el none. */
.logout-container .header-action-icon {
    display: none;
    color: #FFFFFF;
    font-size: 22px;
    text-decoration: none;
}

.header-action-icon:hover {
    opacity: 0.8;
    cursor: pointer;
}

.avatar-header {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: block;
}

.logout-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    gap: 10px;
    position: relative;
}

.user-name-header {
    display: none;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 380px) {
    /* En los teléfonos más angostos el logo cede su lugar al título. */
    .header-logo { display: none; }
}

@media (min-width: 1024px) {
    .header-main { padding-inline: 20px; gap: 16px; }
    .header-burger { display: none; }
    .logo1 { width: 100px; }

    /* Desktop: el título vuelve a centrarse sobre toda la barra. */
    .title-header {
        position: absolute;
        left: 50%;
        top: calc(env(safe-area-inset-top, 0px) + var(--ax-header-h) / 2);
        transform: translate(-50%, -50%);
        flex: none;
        max-width: 40vw;
    }

    .logout-container { margin-left: auto; }
    .logout-container .header-action-icon { display: inline-block; }
    .user-name-header {
        display: block;
        max-width: 240px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.menu-btn {
    font-size: 1em;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    margin: 0;
    width: 50px;
}

.sidebar {
    position: fixed;
    top: 45px;
    left: 0;
    width: 50px;
    height: calc(100% - 40px); 
    background-color: #19415c;
    color: white;
    transition: width 0.3s;
    z-index: 999;
    overflow: hidden;
}

.sidebar.active {
    width: 200px;
}

.sidebar ul {
    list-style-type: none;
    padding: 0;
    margin: 0px 0px 0px 20px;
    font-size: 12px;
    letter-spacing: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar ul li {
    padding: 15px;
    text-align: left;
    position: relative;
    padding-left: 5px;
}

.sidebar ul li a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar li a:hover {
    background-color: #555;
}

.icon {
    margin-right: 10px;
}

.sidebar ul li:hover .submenu {
    display: block;
}

.submenu {
    list-style-type: none;
    padding-left: 20px;
    padding-top: 10px;
}

.submenu li {
    padding: 10px 0;
}

.submenu li a:hover {
    background-color: #555;
}

/* Mobile: el menú es un drawer que no ocupa lugar, el contenido usa todo el
   ancho. Desktop: se deja la franja de 50px del sidebar colapsado. */
.main-content {
    margin-top: var(--ax-top);
    padding: 16px 12px;
}

/* Las vistas del ERP (.ax-page) traen su propio padding mobile-first: si el
   contenedor suma el suyo, en un celular se pierden 24px de ancho útil. */
.main-content:has(> .ax-page) { padding: 0; }

@media (min-width: 1024px) {
    .main-content {
        margin-left: 50px;
        padding: 20px;
    }
}

.hidden {
    display: none;
}

.show {
    display: block;
}

.user-menu-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 7px;
    position: relative; 
}

.user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: #444;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    overflow: hidden;
    font-size: 12px;
}

.user-menu ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.user-menu li {
    border-bottom: 1px solid #555555;
}

/* El link ocupa todo el renglón: 44px de alto para el dedo. */
.user-menu li a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
}

.user-menu li a:hover {
    background-color: #555;
}

/* =========================
   FAVORITOS – HEADER
   ========================= */

/* En mobile los favoritos van dentro del drawer (nav.handlebars). */
.favorites-container {
    display: none;
    align-items: center;
    gap: 8px;
}

@media (min-width: 1024px) {
    .favorites-container { display: flex; }
}

.favorite-icon-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #555555;
    color: #91bcf5;
    font-size: 14px;
    transition: background-color 0.2s;
}

.favorite-icon-header:hover {
    background-color: #666666;
}

/* =========================
   FAVORITOS – ESTRELLA EN CARD
   ========================= */

.favorite-star {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    padding: 0;
    z-index: 50;
    opacity: 1;
}

.favorite-star i {
    color: #888;
}

.favorite-star i.active-star {
    color: #66a2ef;
}

.favorite-star:hover i {
    transform: scale(1.1);
}

/* =========================
   FAVORITOS – SEGMENT BADGE (si aplica)
   ========================= */

.segment-badge {
    display: inline-block;
    background: #4A90E2;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 6px;
}


