.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
    background: var(--color-header);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-brand {
    width: var(--sidebar-width);
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: .5rem 0 0 1rem;
}

.header-brand img {
    display: block;
    max-width: 100%;
    max-height: 50px;
    object-fit: contain;
}

/* Buscador centrado */

.header-search {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(455px, 35%);
    height: 38px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.035);
    transition: border-color var(--transition), background var(--transition);
}

.header-search:focus-within {
    border-color: var(--color-accent);
    background: rgba(255, 255, 255, 0.08);
}

.header-search > i {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
}

.header-search input {
    width: 100%;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #ffffff;
    font-size: 13px;
}

.header-search input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Acciones */

.header-actions {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
    padding: 0 26px;
}

.header-icon {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background var(--transition);
}

.header-icon:hover {
    background: var(--color-header-hover);
}

.header-icon i {
    font-size: 19px;
}

.notification-count {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--color-header);
    border-radius: 20px;
    background: var(--color-error);
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
}

.header-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.18);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 5px 0;
    border: 0;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    text-align: left;
}

.user-menu > img {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.user-info strong {
    font-size: 13px;
    font-weight: 700;
}

.user-info small {
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
}

.user-chevron {
    margin-left: 2px;
    font-size: 11px;
}

/* =========================================================
   HEADER SIDEBAR TOGGLE
   ========================================================= */

.header-sidebar-toggle {
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-left: 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    transition:
        background var(--transition),
        color var(--transition);
}

.header-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-accent);
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 900;
    width: var(--sidebar-width);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--color-sidebar);
    border-right: 1px solid rgba(42, 92, 104, 0.08);
    scrollbar-width: thin;
    scrollbar-color: rgba(42, 92, 104, 0.2) transparent;
    display: flex;
    flex-direction: column;
}

.app-sidebar::-webkit-scrollbar {
    width: 5px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(42, 92, 104, 0.2);
}

.sidebar-navigation {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 18px 16px 24px;
}

/* Footer del sidebar */

.sidebar-footer {
    flex-shrink: 0;
    padding: .15rem .1rem .1rem;
    border-top: 1px solid rgba(42, 92, 104, 0.1);
}
.footer-sidebar-toggle {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 11px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.footer-sidebar-toggle:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-primary);
}

.footer-sidebar-toggle i {
    width: 16px;
    font-size: 14px;
    text-align: center;
}
/* =========================================================
   SIDEBAR HIDDEN
   ========================================================= */

.app-sidebar {
    transition:
        transform 380ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 280ms ease,
        visibility 380ms;
}

.app-main {
    transition:
        margin-left 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-layout.sidebar-hidden .app-sidebar {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-layout.sidebar-hidden .app-main {
    margin-left: 0;
}

.header-sidebar-toggle {
    transition:
        background var(--transition),
        color var(--transition),
        opacity 250ms ease;
}

.app-layout.sidebar-hidden .header-sidebar-toggle {
    display: flex;
}

/* Navigation sections */

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 9px;
}

.nav-section-title {
    padding: 7px 11px 5px;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}


/* Navigation items */

.nav-item {
    position: relative;
    min-height: 35px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 11px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition:
        background var(--transition),
        color var(--transition);
}

/* Main navigation icons */

.nav-item > i:first-child {
    width: 19px;
    flex-shrink: 0;
    color: var(--color-primary);
    font-size: 16px;
    text-align: center;
}

.nav-item > span {
    min-width: 0;
    flex: 1;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-primary-dark);
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: var(--color-text);
}

.nav-item.active > i:first-child {
    color: var(--color-primary-dark);
}

.nav-item.active:hover {
    background: var(--color-accent);
}


/* Navigation groups */

.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group > summary {
    list-style: none;
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

/* Submenu arrow */

.nav-group > summary > .nav-chevron {
    width: 14px;
    flex-shrink: 0;
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 11px;
    text-align: center;
    transition:
        transform var(--transition),
        color var(--transition);
}

.nav-group[open] > summary .nav-chevron {
    transform: rotate(180deg);
    color: var(--color-primary);
}

.nav-group > summary:hover .nav-chevron {
    color: var(--color-primary);
}


/* Submenus */

.nav-submenu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 0;
    overflow: hidden;
    padding-left: 35px;
    opacity: 0;
    transition:
        max-height 250ms ease,
        opacity 200ms ease,
        padding 200ms ease;
}

.nav-group[open] > .nav-submenu {
    max-height: 500px;
    padding-top: 5px;
    padding-bottom: 5px;
    opacity: 1;
}

.nav-submenu a {
    min-height: 28px;
    display: flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition:
        background var(--transition),
        color var(--transition);
}

.nav-submenu a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-primary);
}

.nav-submenu a.active {
    background: rgba(242, 201, 101, 0.3);
    color: var(--color-primary-dark);
    font-weight: 800;
}

.app-main {
    min-height: 100vh;
    min-height: 100dvh;
    margin-left: var(--sidebar-width);
    padding: calc(var(--header-height) + 28px) 30px 40px;
    background: var(--color-background);
    transition: margin-left 250ms ease;
}

/* =========================================================
   USER DROPDOWN
   ========================================================= */

.user-dropdown {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Botón del usuario */

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
    padding: 0 .5rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
}

.user-menu:hover,
.user-menu[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.08);
}

.user-menu > img {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.user-info strong {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.user-info small {
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
}

.user-chevron {
    margin-left: 5px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    transition: transform 220ms ease;
}

.user-menu[aria-expanded="true"] .user-chevron {
    transform: rotate(180deg);
}


/* Panel desplegable */

.user-dropdown-menu {
    position: absolute;
    top: calc(100% - 4px);
    right: 0;
    z-index: 1100;
    width: 235px;
    padding: 8px;
    border: 1px solid rgba(42, 92, 104, 0.09);
    border-radius: var(--radius-md);
    background: #fffefa;
    box-shadow:
        0 12px 35px rgba(31, 65, 73, 0.13),
        0 3px 8px rgba(31, 65, 73, 0.05);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-7px);

    transition:
        opacity 180ms ease,
        transform 180ms ease,
        visibility 180ms;
}

/* Estado abierto */

.user-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(4px);
}


/* Cabecera del desplegable */

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
}

.user-dropdown-header > img {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 2px solid var(--color-accent-light);
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown-header > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-dropdown-header strong {
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 800;
}

.user-dropdown-header span {
    color: var(--color-text-muted);
    font-size: 11px;
}


/* Separador */

.user-dropdown-divider {
    height: 1px;
    margin: 5px 3px;
    background: var(--color-border);
}


/* Opciones */

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 39px;
    padding: 0 11px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition:
        background var(--transition),
        color var(--transition);
}

.user-dropdown-item > i {
    width: 17px;
    color: var(--color-text-muted);
    font-size: 14px;
    text-align: center;
}

.user-dropdown-item.logout {
    color: var(--color-error);
}

.user-dropdown-item.logout > i {
    color: var(--color-error);
}

.user-dropdown-item.logout:hover {
    background: rgba(228, 93, 87, 0.09);
    color: var(--color-error);
}


/* =========================================================
   USER DROPDOWN - MOBILE
   ========================================================= */

@media (max-width: 768px) {

    .user-info,
    .user-chevron {
        display: none;
    }

    .user-menu {
        justify-content: center;
        padding: 0;
    }

    .user-dropdown-menu {
        right: 0;
        width: 225px;
    }

}
