﻿/* ============================================================================
   sidebar.css - Chrome de navegacion (sidebar lateral + topbar) de RRHH.
   Sustituye al navbar horizontal del framework Maga.Web.Mvc.

   ESPEJO DE SIEC
   --------------
   Medidas, colores y estados de este chrome son los de SIEC
   (siag/Content/sidebar.css), regla por regla, para que los dos sistemas se
   vean igual. Antes de retocar un valor aqui, compararlo con ese archivo: lo
   que se ajuste solo de este lado rompe la paridad. Lo que SI es propio de
   RRHH esta marcado con "RRHH:" en su comentario.

   COLORES
   -------
   Las MEDIDAS viven aqui. Los COLORES del sidebar viven en el tema
   (navbar.css / navbarGray.css / navbarGreen.css), que el layout carga DESPUES
   que este archivo y por eso gana. Tocar --sidebar-bg aqui no tiene efecto.

   ORDEN DE CARGA
   --------------
   _Layout.cshtml enlaza este archivo ANTES de los bundles del framework
   (bootstrap.css, Site.css, notificacion.css, el tema). A igual especificidad
   ganan ellos: por eso algunos selectores llevan "body" delante o !important.
   ============================================================================ */

/* Tiene que ser la PRIMERA regla del archivo: un @import despues de cualquier
   otra regla se ignora y la fuente no se descarga. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* --- Geometria: NO la redefinen los temas --- */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --topbar-height: 60px;
    --sidebar-radius: 8px;

    /* --- Color: valores de respaldo. El tema activo los pisa --- */
    --sidebar-bg: #337ab7;
    --sidebar-bg-dark: #286090;
    --sidebar-bg-darker: #1a4d7a;
    --sidebar-text: #ecf0f1;
    --sidebar-text-muted: rgba(236, 240, 241, 0.55);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(255, 255, 255, 0.15);
    --sidebar-border: rgba(255, 255, 255, 0.08);
}

/* ============================================================================
   1. BODY
   El scroll deja de hacerlo el documento y pasa a .content-wrapper.
   ============================================================================ */

html body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body.has-sidebar {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    background: #f4f6f9;
}

/* Anti-FOUC: mata TODAS las transiciones durante el primer pintado.
   El JS quita la clase tras dos requestAnimationFrame. */
body.sidebar-initializing,
body.sidebar-initializing * {
    transition: none !important;
}

/* ============================================================================
   2. SIDEBAR
   ============================================================================ */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    transition: width var(--sidebar-transition), transform var(--sidebar-transition);
    /* visible, no hidden: los tooltips del modo colapsado deben poder salirse */
    overflow: visible;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

/* --- Header y logo --- */

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 20px 16px 16px;
    min-height: 80px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--sidebar-text);
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.sidebar-logo:hover,
.sidebar-logo:focus {
    color: var(--sidebar-text);
    text-decoration: none;
}

/* Pensado para un PNG cuadrado (Images/logo_icono.png). El recuadro
   translucido lo pone la propia <img> con su padding. */
.sidebar-logo img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 14px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px;
}

/* Respaldo cuando no existe el PNG */
.sidebar-logo-icon {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
}

.sidebar-logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    opacity: 1;
    transition: opacity 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    /* RRHH: "Recursos Humanos" no cabe en una linea junto al logo de 64px
       (quedan ~120px) y saldria cortado en puntos suspensivos; se deja
       quebrar en dos. Un nombre corto como "SIEC" se ve igual que alla. */
    white-space: normal;
    line-height: 1.2;
}

.sidebar-collapse-btn {
    width: 32px;
    height: 32px;
    border: none;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ============================================================================
   3. NAVEGACION
   ============================================================================ */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text-muted);
    padding: 16px 14px 6px;
    white-space: nowrap;
    overflow: hidden;
}

/* --- Item y link --- */

.sidebar-item {
    margin-bottom: 2px;
}

/* El color lleva !important para ganarle a la regla "a { color }" de los temas
   (SiteBlue/SiteGray/SiteGreen.css), que se cargan despues. */
.sidebar-link,
.sidebar .sidebar-link,
.sidebar a.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #fff !important;
    text-decoration: none;
    border-radius: var(--sidebar-radius);
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.sidebar-link:hover,
.sidebar .sidebar-link:hover,
.sidebar a.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: #fff !important;
    text-decoration: none;
    transform: translateX(2px);
}

.sidebar-link.active,
.sidebar .sidebar-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff !important;
    font-weight: 600;
    border-left: 3px solid #fff;
    border-radius: 0 var(--sidebar-radius) var(--sidebar-radius) 0;
    /* 14px - 3px de borde, para que el texto no salte al activarse */
    padding-left: 11px;
}

.sidebar-link .sidebar-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-link:hover .sidebar-icon {
    opacity: 1;
}

.sidebar-link .sidebar-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity 0.2s ease;
    /* RRHH: los nombres de menu son mas largos que los de SIEC. En vez de
       cortarlos con puntos suspensivos se dejan quebrar en varias lineas; un
       nombre que cabe en una se ve exactamente igual que alla. */
    white-space: pre-wrap;
}

.sidebar-link .sidebar-chevron {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-item.open > .sidebar-link .sidebar-chevron {
    transform: rotate(90deg);
    opacity: 1;
}

/* RRHH: contador de notificaciones del framework (scaffolding.notifications.js
   le escribe el total). Se viste como el .sidebar-badge de SIEC.
   notificacion.css lo posiciona para el navbar horizontal con top:-15px; aqui
   se reencuadra. Lleva "body" delante porque ese archivo se carga despues. */
body .sidebar-link > .badge-notify {
    position: static;
    top: auto;
    flex-shrink: 0;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1.5;
}

/* Vacio no debe dibujar la pastilla */
body .sidebar-link > .badge-notify:empty {
    display: none;
}

/* ============================================================================
   4. SUBMENUS
   Acordeon por ALTURA animada, no por display. El JS calcula scrollHeight y
   en el transitionend pasa a "auto" para admitir contenido dinamico.
   El padding vertical de 4px + 4px que aparece al abrir esta duplicado en el
   JS de Menu.cshtml (SUBMENU_PAD): si cambia aqui, cambiarlo alla.
   ============================================================================ */

.sidebar-submenu {
    list-style: none;
    padding: 0 0 0 8px;
    margin: 0 0 0 18px;
    height: 0;
    overflow: hidden;
    background-color: transparent;
    transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                padding-top 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                padding-bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.2s ease;
    border-left: none;
    border-radius: var(--sidebar-radius);
}

.sidebar-item.open > .sidebar-submenu {
    padding-top: 4px;
    padding-bottom: 4px;
    border-left: none;
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-submenu .sidebar-link {
    padding: 7px 10px 7px 16px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.78) !important;
    border-radius: var(--sidebar-radius);
}

.sidebar-submenu .sidebar-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-submenu .sidebar-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.18);
    font-weight: 600;
    border-left: 3px solid #fff;
    border-radius: 0 var(--sidebar-radius) var(--sidebar-radius) 0;
    padding-left: 13px;
}

/* Nivel 3: sin guia vertical, se separa por fondo */
.sidebar-submenu .sidebar-submenu {
    margin-left: 10px;
    border-left: none;
}

.sidebar-submenu > .sidebar-item.open > .sidebar-submenu {
    border-left: none;
    background: rgba(255, 255, 255, 0.035);
}

.sidebar-submenu .sidebar-submenu .sidebar-link {
    padding-left: 14px;
    font-size: 0.78rem;
}

/* ============================================================================
   5. FOOTER DEL SIDEBAR
   ============================================================================ */

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 12px 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

/* Es un <button>: no navega, dispara el modal de confirmacion */
.sidebar-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: transparent;
    color: #ff5b6a;
    border: none;
    border-radius: var(--sidebar-radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar-logout-btn .fas {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: inherit;
    opacity: 1;
}

.sidebar-logout-btn:hover,
.sidebar-logout-btn:focus {
    background: var(--sidebar-hover-bg);
    color: #ff5b6a;
    outline: none;
    transform: translateX(2px);
}

.sidebar-logout-text {
    flex: 1;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease, width 0.2s ease;
}

/* ============================================================================
   6. OVERLAY (solo movil)
   ============================================================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

/* ============================================================================
   7. CONTENIDO
   .main-content es HERMANO de .sidebar, no lo contiene. El desplazamiento lo
   hace margin-left, y por eso colapsar el sidebar es solo cambiar dos anchos.
   ============================================================================ */

.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

/* AQUI vive el scroll real de la aplicacion */
.content-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    scrollbar-gutter: stable;
}

.content-wrapper.is-overflowing-x {
    overflow-x: auto;
}

.app-footer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid #e5e9ef;
    color: #8a94a6;
    font-size: .75rem;
    text-align: center;
}

/* Los alerts del scaffolding son position:fixed y no traen "top": hay que
   bajarlos para que no queden debajo de la topbar. */
body.has-sidebar .alert-container {
    top: calc(var(--topbar-height) + 12px);
    z-index: 4600;
}

/* ============================================================================
   8. TOPBAR
   Va DENTRO de .main-content, no fuera: asi se corre junto con el contenido
   cuando el sidebar se colapsa. Solo existe cuando hay sesion; sin ella el
   layout emite la .mini-topbar de la seccion 14.
   ============================================================================ */

.topbar {
    height: var(--topbar-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
    z-index: 4500;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-toggle {
    width: 38px;
    height: 38px;
    border: none;
    padding: 0;
    background: #f4f6f9;
    color: #555;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.topbar-toggle:hover {
    background: #e8ecf1;
    color: #333;
}

/* Marca: solo en movil, cuando el sidebar es un cajon oculto. Igual que en
   SIEC va SOLO el nombre; el logo se queda en el header del cajon. */
.topbar-brand {
    display: none;
    align-items: center;
    gap: 10px;
    color: #243142;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    /* RRHH: el nombre es mas largo que "SIEC"; en un telefono angosto tiene
       que poder encogerse en vez de empujar el avatar fuera de la pantalla. */
    min-width: 0;
    flex: 0 1 auto;
}

.topbar-brand:hover,
.topbar-brand:focus {
    color: var(--sidebar-bg, #337ab7);
    text-decoration: none;
}

.topbar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title {
    font-size: 1.14rem;
    font-weight: 600;
    color: #333;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.topbar-breadcrumb-separator {
    flex-shrink: 0;
    color: #a0aec0;
    font-size: 0.72rem;
}

.topbar-breadcrumb-context {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #718096;
    font-weight: 700;
}

.topbar-breadcrumb-current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #2d3748;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
    margin-left: auto;
}

.topbar-icon-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
}

.topbar-icon-btn:hover {
    background: #f4f6f9;
    color: #333;
    text-decoration: none;
}

/* RRHH: punto de aviso de la campana. El markup es el del navbar anterior
   (span.badge.badge-danger); se viste como el .topbar-badge de SIEC. Lleva
   "body" delante porque notificacion.css y bootstrap se cargan despues. */
body .topbar-icon-btn > .badge-notify-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    min-width: 0;
    padding: 0;
    background: #e74c3c;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
}

/* ============================================================================
   9. MENU DE USUARIO
   Reimplementado a mano: no depende del dropdown de Bootstrap.
   RRHH: el disparador es un <button> dentro de .topbar-user (en SIEC es el
   propio div); la pastilla se pinta sobre el boton y se ve igual.
   Las clases .dropdown-header / .dropdown-divider coinciden a proposito con
   las de Bootstrap, igual que en SIEC: lo que aqui no se pisa (por ejemplo el
   white-space: nowrap del encabezado) se hereda de el.
   ============================================================================ */

.topbar-user {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
    background: #f6f8fb;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
    color: inherit;
}

.topbar-user-trigger:hover,
.topbar-user.open .topbar-user-trigger {
    background: #eef2f7;
}

.topbar-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--sidebar-bg, #337ab7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    flex-shrink: 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    max-width: 180px;
}

.topbar-user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #243142;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-caret {
    color: #a0aec0;
    font-size: 0.72rem;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.topbar-user.open .topbar-user-caret {
    transform: rotate(180deg);
}

.topbar-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #f5f7fa;
    border: 1px solid #d8dee7;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    padding: 4px 0;
    display: none;
    z-index: 6000;
    min-width: 240px;
    animation: topbarDropdown 0.2s ease;
}

.topbar-user.open .topbar-user-dropdown {
    display: block;
}

@keyframes topbarDropdown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.topbar-user-dropdown .dropdown-header {
    text-align: center;
    padding: 14px 18px 12px;
    background: linear-gradient(180deg, #eef2f7 0%, #f8fafc 100%);
    border-bottom: 1px solid #d8dee7;
    margin: -4px 0 6px;
    border-radius: 9px 9px 0 0;
}

.topbar-user-dropdown .dropdown-header .user-full-name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.25;
    color: #1e293b;
    word-break: break-word;
}

.topbar-user-dropdown .dropdown-header .user-email {
    margin-top: 4px;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.35;
    word-break: break-word;
}

.topbar-user-dropdown .dropdown-header .user-email-local {
    display: block;
    font-weight: 600;
    color: #475569;
}

.topbar-user-dropdown .dropdown-header .user-email-domain {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
}

.topbar-user-dropdown .dropdown-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    color: #334155;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
    margin: 0 4px;
    border-radius: 6px;
}

.topbar-user-dropdown .dropdown-link .fas {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    color: #64748b;
}

.topbar-user-dropdown .dropdown-link:hover {
    background: #ffffff;
    color: #1e293b;
}

.topbar-user-dropdown .dropdown-link.dropdown-link-danger,
.topbar-user-dropdown .dropdown-link.dropdown-link-danger .fas {
    color: #dc3545;
}

.topbar-user-dropdown .dropdown-link.dropdown-link-danger:hover {
    background: #ffe3e6;
    color: #b21f2d;
}

.topbar-user-dropdown .dropdown-link.dropdown-link-danger:hover .fas {
    color: #b21f2d;
}

.topbar-user-dropdown .dropdown-section-title {
    padding: 4px 14px 2px;
    color: #8a97a6;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar-user-dropdown .dropdown-divider {
    height: 0;
    border-top: 1px solid #d8dee7;
    margin: 2px 12px;
}

.topbar-user-dropdown .theme-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 4px 0 6px;
}

.topbar-user-dropdown .theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    display: inline-block;
}

.topbar-user-dropdown .theme-dot:hover {
    transform: scale(1.2);
    border-color: rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   10. ESTADO COLAPSADO (solo escritorio)
   La clase "sidebar-collapsed" va al <body>, NO al <aside>.
   Los textos se ocultan con opacity/width, nunca con display:none, para que la
   transicion sea suave.
   RRHH: todo el bloque vive dentro de min-width:992px. "sidebar-collapsed" y
   el cajon movil son mecanismos independientes: si la ventana se achica con
   el sidebar colapsado, la clase sigue en el body pero el cajon sale completo.
   ============================================================================ */

@media (min-width: 992px) {

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
        overflow: visible;
    }

    body.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .sidebar-nav {
        overflow-y: auto;
        overflow-x: visible;
    }

    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-text,
    body.sidebar-collapsed .sidebar-chevron,
    body.sidebar-collapsed .sidebar-logout-text {
        opacity: 0;
        width: 0;
        overflow: hidden;
        pointer-events: none;
    }

    /* RRHH: flex:0 0 0 y no solo width:0. Estos textos son flex:1, y con
       flex-grow intacto se estiran para llenar el hueco aunque midan 0 de
       ancho: se comen el espacio libre y dejan el icono 6px a la izquierda
       del centro del riel. nowrap evita que, con ancho 0, el texto quiebre
       palabra por palabra y estire el alto del item. */
    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .sidebar-text,
    body.sidebar-collapsed .sidebar-chevron,
    body.sidebar-collapsed .sidebar-logout-text {
        flex: 0 0 0;
        white-space: nowrap;
    }

    body.sidebar-collapsed .sidebar-header {
        padding: 14px 8px;
        min-height: auto;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-logo {
        justify-content: center;
        /* El gap sigue ocupando aunque el texto mida 0 */
        gap: 0;
    }

    body.sidebar-collapsed .sidebar-logo img {
        width: 44px;
        height: 44px;
        padding: 4px;
        border-radius: 10px;
    }

    body.sidebar-collapsed .sidebar-logo-icon {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    /* El boton de colapsar desaparece: se reabre desde la hamburguesa de la topbar */
    body.sidebar-collapsed .sidebar-collapse-btn {
        display: none;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 10px;
        gap: 0;
    }

    /* El activo pierde el borde izquierdo y gana fondo mas fuerte con anillo */
    body.sidebar-collapsed .sidebar-link.active {
        border-left: none;
        border-radius: var(--sidebar-radius);
        padding-left: 10px;
        background: rgba(255, 255, 255, 0.22);
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) inset;
    }

    /* Padre con un descendiente activo: mismo realce, mas un punto ambar arriba
       a la derecha, para no perder de vista donde se esta cuando los textos no
       se ven. La clase has-active-child la pone el JS de Menu.cshtml. */
    body.sidebar-collapsed .sidebar-item.has-active-child > .sidebar-link {
        background: rgba(255, 255, 255, 0.22);
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) inset;
        color: #fff !important;
        border-radius: var(--sidebar-radius);
    }

    body.sidebar-collapsed .sidebar-item.has-active-child > .sidebar-link::after {
        content: "";
        position: absolute;
        top: 6px;
        right: 6px;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #ffd166;
        box-shadow: 0 0 0 2px var(--sidebar-bg);
    }

    body.sidebar-collapsed .sidebar-submenu {
        max-height: 0 !important;
        height: 0 !important;
        margin-left: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-left: none;
    }

    body.sidebar-collapsed .sidebar-logout-btn {
        justify-content: center;
        padding: 10px;
        gap: 0;
    }

    /* RRHH: el contador de notificaciones se queda visible, en miniatura */
    body.sidebar-collapsed .sidebar-link > .badge-notify {
        position: absolute;
        top: 2px;
        right: 2px;
        padding: 0 4px;
        font-size: 0.6rem;
    }
}

/* ============================================================================
   11. TOOLTIPS
   Solo existen en modo colapsado y los maneja el JavaScript, no el CSS: hay un
   unico div colgado del <body>, posicionado con getBoundingClientRect() y
   alimentado por el atributo data-title de cada link.
   ============================================================================ */

.sidebar-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    background: #2d3748;
    color: #fff !important;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 99999;
    /* No debe capturar el mouse: flota sobre todo sin estorbar */
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    font-family: 'Inter', sans-serif;
}

.sidebar-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   12. MODAL DE CONFIRMACION DE SALIDA
   Propio, no de Bootstrap.
   ============================================================================ */

.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    /* RRHH: por encima de los modales de Bootstrap y de SweetAlert2, que la
       seccion 13 sube a 9600 / 9700 */
    z-index: 9800;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: confirmFade 0.18s ease;
}

.confirm-modal.open {
    display: flex;
}

@keyframes confirmFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.confirm-modal-dialog {
    background: #fff;
    border-radius: 14px;
    padding: 28px 28px 22px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: confirmPop 0.22s ease;
}

@keyframes confirmPop {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #fff5f5;
    color: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.confirm-modal-title {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #243142;
}

.confirm-modal-text {
    margin: 0 0 20px;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.5;
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-modal-actions .btn-cancel,
.confirm-modal-actions .btn-confirm {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}

.confirm-modal-actions .btn-cancel {
    background: #f1f5f9;
    color: #334155;
}

.confirm-modal-actions .btn-cancel:hover {
    background: #e2e8f0;
}

.confirm-modal-actions .btn-confirm {
    background: #dc3545;
    color: #fff;
}

.confirm-modal-actions .btn-confirm:hover,
.confirm-modal-actions .btn-confirm:focus {
    background: #c82333;
    color: #fff;
    text-decoration: none;
}

/* ============================================================================
   13. INTEROPERABILIDAD CON BOOTSTRAP Y SWEETALERT2 (RRHH)
   Esta hoja se enlaza ANTES de bootstrap.css y del tema, asi que a igual
   especificidad ganarian ellas. Los selectores llevan "body" delante para
   subir de especificidad sin recurrir a !important.
   ============================================================================ */

/* El sidebar esta en 5000 y la topbar en 4500, por encima del z-index nativo
   de los modales de Bootstrap (1050) y de SweetAlert2 (1060), lo que dejaba
   los modales "cortados". Se elevan por encima del chrome. */
body .modal-backdrop {
    z-index: 9500;
}

body .modal {
    z-index: 9600;
}

body .swal2-container {
    z-index: 9700;
}

/* Limite de ancho del contenido. Aplica a las clases genericas de Bootstrap
   que las vistas usan como contenedores: una tarjeta que "no se ensancha" no
   tiene nada malo en su propio CSS, la esta limitando esta hoja. */
body.has-sidebar .content-wrapper .form-group.row {
    /*max-width: 1200px;*/
    margin-left: auto;
    margin-right: auto;
}

body.has-sidebar .content-wrapper .bs-callout,
body.has-sidebar .content-wrapper .alert:not(.alert-div),
body.has-sidebar .content-wrapper .table-responsive {
    /*max-width: 1200px;*/
    margin-left: auto;
    margin-right: auto;
}

/* Bootstrap pinta un outline en button:focus tambien al hacer click con el
   mouse. Se quita aqui y se devuelve solo para el teclado. */
body .sidebar button:focus,
body .topbar button:focus,
body .confirm-modal button:focus {
    outline: none;
}

body .sidebar button:focus-visible,
body .sidebar-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: -2px;
}

body .topbar button:focus-visible {
    outline: 2px solid var(--sidebar-bg);
    outline-offset: 1px;
}

/* ============================================================================
   14. CHROME SIN SIDEBAR
   Login, Registro, error fatal: no hay menu que mostrar, asi que el chrome se
   reduce a una barra del color del tema (la .mini-topbar de SIEC) y el
   documento recupera su scroll. El layout ya marca el body como "no-sidebar"
   en servidor, de modo que no hay parpadeo.
   ============================================================================ */

body.no-sidebar {
    height: auto;
    overflow: visible;
    padding-top: 0;
}

body.no-sidebar .main-content {
    height: auto;
    margin-left: 0;
    background: none;
}

body.no-sidebar .content-wrapper {
    overflow: visible;
    padding: 0;
}

.mini-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 56px;
    height: var(--topbar-height, 60px);
    flex-shrink: 0;
    background: var(--sidebar-bg, #337ab7);
    color: var(--sidebar-text, #ecf0f1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 4500;
}

.mini-topbar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--sidebar-text, #ecf0f1);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    min-width: 0;
}

.mini-topbar .brand:hover,
.mini-topbar .brand:focus {
    color: #fff;
    text-decoration: none;
}

.mini-topbar .brand img {
    height: 36px;
    width: 36px;
    flex-shrink: 0;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 4px;
}

.mini-topbar .brand .mini-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    width: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.05rem;
}

.mini-topbar .brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-topbar .mini-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    color: #fff;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 18px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.mini-topbar .mini-action:hover,
.mini-topbar .mini-action:focus {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.18);
    text-decoration: none;
}

/* ============================================================================
   15. RESPONSIVE
   Por debajo de 992px el sidebar se vuelve un cajon deslizante: conserva sus
   260px y sale de pantalla con translateX. La topbar se queda con la
   hamburguesa, el nombre del sistema, la campana y el avatar.
   ============================================================================ */

@media (max-width: 991.98px) {

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.2);
        overflow: hidden;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.mobile-open ~ .sidebar-overlay,
    .sidebar-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    /* En movil el contenido nunca se desplaza: el cajon flota encima */
    .main-content {
        margin-left: 0 !important;
    }

    /* Colapsar no existe en movil */
    .sidebar-collapse-btn {
        display: none;
    }

    .topbar {
        padding: 0 16px;
    }

    /* La marca aparece porque el logo del sidebar no se ve... */
    .topbar-brand {
        display: inline-flex;
    }

    /* ...y el titulo le cede el espacio */
    .topbar-title {
        display: none;
    }

    /* El usuario queda reducido al avatar */
    .topbar-user-info,
    .topbar-user-caret {
        display: none;
    }

    .topbar-user-trigger {
        padding: 2px;
        background: transparent;
    }

    .topbar-user-trigger:hover,
    .topbar-user.open .topbar-user-trigger {
        background: #e2e8f0;
    }

    .content-wrapper {
        padding: 16px;
    }

    /* Los tooltips no tienen sentido sin modo colapsado */
    .sidebar-tooltip {
        display: none;
    }
}

@media (max-width: 767.98px) {

    body.has-sidebar .alert-container {
        width: 90%;
    }
}

@media (max-width: 575.98px) {

    .content-wrapper {
        padding: 12px;
    }

    .mini-topbar {
        padding: 10px 28px;
    }

    .mini-topbar .brand {
        font-size: 1rem;
        gap: 10px;
    }

    .mini-topbar .brand img,
    .mini-topbar .brand .mini-brand-icon {
        height: 32px;
        width: 32px;
    }

    .mini-topbar .mini-action {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    /* RRHH: el encabezado del menu de usuario hereda white-space:nowrap de
       Bootstrap y un nombre completo largo lo sacaria de la pantalla de un
       telefono. Con max-content el panel mide lo mismo que con nowrap mientras
       quepa; solo cuando no cabe se topa con el max-width y el nombre quiebra. */
    .topbar-user-dropdown {
        width: max-content;
        max-width: calc(100vw - 32px);
    }

    .topbar-user-dropdown .dropdown-header {
        white-space: normal;
    }
}
