﻿/* ============================================================================
   sidebar.css - Chrome de navegacion (sidebar lateral + topbar) de RRHH.
   Sustituye al navbar horizontal del framework Maga.Web.Mvc.

   REGLA DE ORO
   ------------
   Las MEDIDAS viven aqui. Los COLORES 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 ningun 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 varios selectores llevan "body" delante a proposito,
   para subir de especificidad sin recurrir a !important.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@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, .55);
    --sidebar-hover-bg: rgba(255, 255, 255, .08);
    --sidebar-active-bg: rgba(255, 255, 255, .18);
    --sidebar-border: rgba(255, 255, 255, .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-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);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 5000;
    /* visible, no hidden: los tooltips del modo colapsado deben poder salirse */
    overflow: visible;
    transition: width var(--sidebar-transition), transform var(--sidebar-transition);
}

/* --- Header y logo --- */

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 72px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    text-decoration: none;
    color: var(--sidebar-text);
}

.sidebar-logo:hover,
.sidebar-logo:focus {
    text-decoration: none;
    color: var(--sidebar-text);
}

/* El recuadro es este span, NO la <img>. Pensado para un PNG cuadrado
   con aire propio; otro aspect-ratio obliga a reajustar estas reglas. */
.sidebar-logo-badge {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .14);
    border-radius: 10px;
    overflow: hidden;
}

body .sidebar-logo-badge > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-logo-icon {
    font-size: 1.15rem;
    color: var(--sidebar-text);
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
    overflow: hidden;
}

.sidebar-logo-title {
    /* El nombre va en UNA linea. Con el badge de 44 y los gaps de 10 no cabia
       (147px contra 136 disponibles); al compactar el header sobra espacio y se
       conserva el tamano original. */
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logo-subtitle {
    font-size: .68rem;
    font-weight: 500;
    color: var(--sidebar-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-collapse-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .10);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background .2s ease;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, .22);
}

.sidebar-collapse-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .7);
    outline-offset: 1px;
}

/* ============================================================================
   3. NAVEGACION
   ============================================================================ */

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px 4px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .25) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .25);
    border-radius: 4px;
}

.sidebar-section-label {
    padding: 4px 10px 8px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-menu,
.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-item {
    position: relative;
}

/* --- Link --- */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: var(--sidebar-radius);
    border-left: 3px solid transparent;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, transform .18s ease, padding-left .18s ease;
}

/* Los links del sidebar necesitan !important para ganarle a la regla "a { color }"
   de los temas (SiteBlue/SiteGray/SiteGreen.css), que se cargan despues. */
.sidebar-link,
.sidebar-link:link,
.sidebar-link:visited,
.sidebar-link:hover,
.sidebar-link:focus,
.sidebar-link:active {
    color: var(--sidebar-text) !important;
    text-decoration: none !important;
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    transform: translateX(2px);
}

.sidebar-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .7);
    outline-offset: -2px;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    font-weight: 700;
    border-left-color: #fff;
    /* 12px - 3px de borde, para que el texto no salte al activarse */
    padding-left: 9px;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    opacity: .92;
}

.sidebar-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: pre-wrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-chevron {
    flex-shrink: 0;
    font-size: .7rem;
    opacity: .75;
    transition: transform var(--sidebar-transition);
}

.sidebar-item.open > .sidebar-link > .sidebar-chevron {
    transform: rotate(90deg);
}

/* Contador de notificaciones del framework (scaffolding.notifications.js le
   escribe el total). 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;
    min-width: 20px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #ffd166;
    color: #4a3400;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.3;
}

/* 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.
   Tres niveles: el fondo se aclara y la letra baja de tamano. Sin guias
   verticales.
   ============================================================================ */

.sidebar-submenu {
    height: 0;
    overflow: hidden;
    transition: height var(--sidebar-transition);
}

.sidebar-submenu .sidebar-link {
    padding-left: 25px;
    font-size: .82rem;
    font-weight: 400;
    background: rgba(255, 255, 255, .04);
}

.sidebar-submenu .sidebar-link:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar-submenu .sidebar-link.active {
    background: var(--sidebar-active-bg);
    font-weight: 600;
    padding-left: 39px;
}

/* Nivel 3 */
.sidebar-submenu .sidebar-submenu .sidebar-link {
    padding-left: 45px;
    font-size: .78rem;
    background: rgba(255, 255, 255, .035);
}

.sidebar-submenu .sidebar-submenu .sidebar-link.active {
    padding-left: 50px;
}

.sidebar-submenu .sidebar-icon {
    font-size: .78rem;
    opacity: .8;
}

/* ============================================================================
   5. FOOTER DEL SIDEBAR
   ============================================================================ */

.sidebar-footer {
    flex-shrink: 0;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--sidebar-border);
}

/* Es un <button>: no navega, dispara el modal de confirmacion */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--sidebar-radius);
    background: rgba(255, 255, 255, .08);
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background .2s ease;
}

.sidebar-logout-btn:hover {
    background: rgba(255, 255, 255, .2);
}

.sidebar-logout-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .7);
    outline-offset: -2px;
}

/* ============================================================================
   6. OVERLAY (solo movil)
   ============================================================================ */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 4999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--sidebar-transition), visibility 0s linear .3s;
}

/* ============================================================================
   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 var(--sidebar-transition);
}

/* AQUI vive el scroll real de la aplicacion */
.content-wrapper {
    flex: 1 1 auto;
    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.
   ============================================================================ */

.topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-height);
    padding: 0 18px;
    background: #fff;
    border-bottom: 1px solid #e5e9ef;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
    z-index: 4500;
}

.topbar-toggle {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #5a6472;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.topbar-toggle:hover {
    background: #f1f4f8;
    color: var(--sidebar-bg);
}

.topbar-toggle:focus-visible {
    outline: 2px solid var(--sidebar-bg);
    outline-offset: 1px;
}

/* Marca: solo visible en movil, cuando el sidebar es un cajon oculto */
.topbar-brand {
    display: none;
    align-items: center;
    gap: 8px;
    min-width: 0;
    text-decoration: none;
    color: #2b3444;
}

.topbar-brand:hover,
.topbar-brand:focus {
    text-decoration: none;
    color: #2b3444;
}

body .topbar-brand > img {
    height: 30px;
    width: auto;
    display: block;
}

.topbar-brand-text {
    font-size: .9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .95rem;
    font-weight: 600;
    color: #2b3444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title .topbar-title-parent {
    font-weight: 500;
    color: #8a94a6;
}

.topbar-title .topbar-title-sep {
    margin: 0 6px;
    color: #c3cad6;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.topbar-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1rem;
    transition: background .2s ease, color .2s ease;
}

.topbar-icon-btn,
.topbar-icon-btn:link,
.topbar-icon-btn:visited {
    color: #5a6472 !important;
    text-decoration: none !important;
}

.topbar-icon-btn:hover,
.topbar-icon-btn:focus {
    background: #f1f4f8;
    color: var(--sidebar-bg) !important;
    text-decoration: none !important;
}

/* Punto de aviso. Lleva "body" delante porque notificacion.css y bootstrap
   se cargan despues de esta hoja. */
body .topbar-icon-btn > .badge-notify-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    min-width: 0;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
}

/* ============================================================================
   9. MENU DE USUARIO
   Reimplementado a mano: este markup se emite antes de que jQuery exista, asi
   que no se puede depender del dropdown de Bootstrap.
   ============================================================================ */

.topbar-user {
    position: relative;
    flex-shrink: 0;
}

.topbar-user-trigger {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: 240px;
    padding: 5px 10px 5px 5px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #2b3444;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s ease;
}

.topbar-user-trigger:hover {
    background: #f1f4f8;
}

.topbar-user-trigger:focus-visible {
    outline: 2px solid var(--sidebar-bg);
    outline-offset: 1px;
}

.topbar-user-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.topbar-user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.2;
}

.topbar-user-name {
    font-size: .8rem;
    font-weight: 600;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-role {
    font-size: .68rem;
    font-weight: 500;
    color: #8a94a6;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-caret {
    flex-shrink: 0;
    font-size: .65rem;
    color: #8a94a6;
    transition: transform .2s ease;
}

.topbar-user.open .topbar-user-caret {
    transform: rotate(180deg);
}

.topbar-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(280px, calc(100vw - 32px));
    padding: 6px 0;
    background: #fff;
    border: 1px solid #e5e9ef;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
    z-index: 4700;
}

.topbar-user.open .topbar-user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity .18s ease, transform .18s ease, visibility 0s;
}

.topbar-user-card {
    padding: 10px 14px 12px;
    text-align: center;
    background: #f7f9fc;
    border-bottom: 1px solid #e5e9ef;
}

.topbar-user-card-name {
    font-size: .85rem;
    font-weight: 700;
    color: #2b3444;
    line-height: 1.2;
}

.topbar-user-card-mail {
    margin-top: 3px;
    font-size: .76rem;
    font-weight: 600;
    color: #6b7686;
    word-break: break-all;
}

.topbar-user-card-domain {
    font-size: .68rem;
    color: #8a94a6;
}

.topbar-themes-label {
    padding: 8px 14px 2px;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #a0a9b8;
    text-align: center;
}

.topbar-themes {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 4px 0 10px;
}

.topbar-theme-dot {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform .15s ease, border-color .15s ease;
}

.topbar-theme-dot:hover {
    transform: scale(1.15);
    border-color: #d5dbe4;
}

.topbar-menu-divider {
    height: 1px;
    margin: 5px 0;
    background: #eceff4;
}

.topbar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 6px;
    padding: 8px 12px;
    border-radius: 7px;
    font-size: .82rem;
    transition: background .18s ease, color .18s ease;
}

.topbar-menu-item,
.topbar-menu-item:link,
.topbar-menu-item:visited {
    color: #4b5563 !important;
    text-decoration: none !important;
}

.topbar-menu-item:hover,
.topbar-menu-item:focus {
    background: #f4f6f9;
    color: var(--sidebar-bg) !important;
    text-decoration: none !important;
}

.topbar-menu-item > .topbar-menu-icon {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    font-size: .82rem;
}

.topbar-menu-item.is-danger,
.topbar-menu-item.is-danger:link,
.topbar-menu-item.is-danger:visited {
    color: #c0392b !important;
}

.topbar-menu-item.is-danger:hover,
.topbar-menu-item.is-danger:focus {
    background: #fdf0ee;
    color: #a5281b !important;
}

/* Boton dentro del dropdown (Salir con confirmacion) */
button.topbar-menu-item {
    width: calc(100% - 12px);
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

/* ============================================================================
   10. ESTADO COLAPSADO
   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.
   ============================================================================ */

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-header {
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
}

body.sidebar-collapsed .sidebar-logo {
    flex: 0 0 auto;
    justify-content: center;
    /* El gap sigue ocupando aunque el texto mida 0: 38 + 10 = 48 centrado en
       56 deja el badge 5px a la izquierda del centro del riel. */
    gap: 0;
}

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .sidebar-chevron,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-logout-btn > span:not(.sidebar-icon) {
    opacity: 0;
    /* flex:0 0 0 y no solo width:0. .sidebar-text es flex:1 1 auto, y con
       flex-grow intacto se estira para llenar el hueco aunque mida 0 de ancho:
       se come el espacio libre y empuja el icono contra el borde izquierdo,
       dejando sin efecto el justify-content:center del link. */
    flex: 0 0 0;
    width: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity .12s ease;
}

/* 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-nav {
    padding-left: 8px;
    padding-right: 8px;
    overflow-x: visible;
    /* Sin esto, el hueco reservado para la barra de scroll (~10px a la derecha)
       descentra los iconos: 72 - 8 - 8 - 10 = 46 de ancho util, con centro en 31
       en vez de 36. Expandido si conviene, porque evita el salto al aparecer el
       scroll mientras se lee el texto; colapsado no hay texto que saltar. */
    scrollbar-gutter: auto;
}

body.sidebar-collapsed .sidebar-section-label {
    padding: 0;
    height: 8px;
}

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-logout-btn {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    border-left-width: 0;
}

body.sidebar-collapsed .sidebar-link:hover {
    transform: none;
}

/* El activo pierde el borde izquierdo y gana fondo mas fuerte con anillo */
body.sidebar-collapsed .sidebar-link.active {
    padding-left: 0;
    background: rgba(255, 255, 255, .22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}

/* Padre con un hijo activo: punto ambar arriba a la derecha, para no perder
   de vista donde se esta cuando los textos no se ven. */
body.sidebar-collapsed .sidebar-item.has-active-child > .sidebar-link::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffd166;
}

body.sidebar-collapsed .sidebar-submenu {
    max-height: 0;
    height: 0 !important;
    overflow: hidden;
}

/* Proporciones del riel colapsado. Expandido el icono acompana a un texto de
   0.875rem y 20px basta; en 72px sin texto se queda flotando, asi que sube.
   El logo baja de 44 a 38 para no aplastar a los iconos por contraste. */
body.sidebar-collapsed .sidebar-icon {
    width: 24px;
    height: 24px;
    font-size: 1.05rem;
    opacity: 1;
}

body.sidebar-collapsed .sidebar-logo-badge {
    width: 38px;
    height: 38px;
    border-radius: 9px;
}

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-logout-btn {
    padding-top: 10px;
    padding-bottom: 10px;
}

body.sidebar-collapsed .sidebar-logout-btn > .sidebar-icon {
    margin: 0 auto;
}

body.sidebar-collapsed .sidebar-link > .badge-notify {
    position: absolute;
    top: 2px;
    right: 4px;
    min-width: 16px;
    padding: 0 4px;
    font-size: .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;
    z-index: 99999;
    max-width: 240px;
    padding: 6px 10px;
    background: #1f2733;
    color: #fff;
    border-radius: 6px;
    font-family: 'Inter', -apple-system, 'Segoe UI', Arial, sans-serif;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(16, 24, 40, .28);
    opacity: 0;
    visibility: hidden;
    /* No debe capturar el mouse: flota sobre todo sin estorbar */
    pointer-events: none !important;
    transition: opacity .14s ease, visibility .14s ease;
}

.sidebar-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   12. MODAL DE CONFIRMACION DE SALIDA
   Propio, no de Bootstrap: este markup se emite antes de que exista jQuery.
   ============================================================================ */

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 9800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 24, 40, .5);
    opacity: 0;
    visibility: hidden;
    /* visibility solo se retarda al CERRAR; al abrir es inmediata para que
       focus() funcione en el mismo frame */
    transition: opacity .18s ease, visibility 0s linear .18s;
}

.confirm-modal.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .18s ease, visibility 0s;
}

.confirm-modal-box {
    width: min(400px, 100%);
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
    text-align: center;
    transform: translateY(-10px) scale(.98);
    transition: transform .18s ease;
}

.confirm-modal.open .confirm-modal-box {
    transform: translateY(0) scale(1);
}

.confirm-modal-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fdf0ee;
    color: #c0392b;
    font-size: 1.3rem;
}

.confirm-modal-title {
    margin: 0 0 6px;
    font-size: 1.02rem;
    font-weight: 700;
    color: #2b3444;
}

.confirm-modal-text {
    margin: 0 0 20px;
    font-size: .85rem;
    color: #6b7686;
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-modal-btn {
    min-width: 110px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.confirm-modal-btn.is-cancel {
    background: #fff;
    border-color: #d5dbe4;
    color: #4b5563;
}

.confirm-modal-btn.is-cancel:hover {
    background: #f4f6f9;
}

.confirm-modal-btn.is-confirm,
.confirm-modal-btn.is-confirm:link,
.confirm-modal-btn.is-confirm:visited {
    background: #c0392b;
    color: #fff !important;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal-btn.is-confirm:hover {
    background: #a5281b;
}

/* ============================================================================
   13. INTEROPERABILIDAD CON BOOTSTRAP Y SWEETALERT2
   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;
}

/* ============================================================================
   14. RESPONSIVE
   El sidebar se vuelve un cajon deslizante: conserva sus 260px y sale de
   pantalla con translateX. "sidebar-collapsed" y el modo movil son mecanismos
   INDEPENDIENTES: en movil el sidebar nunca mide 72px, o esta fuera o esta
   completo.
   ============================================================================ */

@media (max-width: 991.98px) {

    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, .25);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.mobile-open ~ .sidebar-overlay,
    .sidebar-overlay.visible {
        opacity: 1;
        visibility: visible;
        transition: opacity var(--sidebar-transition), visibility 0s;
    }

    /* En movil el contenido nunca se desplaza: el cajon flota encima */
    .main-content,
    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }

    /* El colapsado no aplica en movil: el cajon siempre va completo */
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
    }

    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .sidebar-text,
    body.sidebar-collapsed .sidebar-chevron,
    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-logout-btn > span:not(.sidebar-icon) {
        opacity: 1;
        width: auto;
        overflow: visible;
        pointer-events: auto;
    }

    body.sidebar-collapsed .sidebar-header {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-logout-btn {
        justify-content: flex-start;
        gap: 10px;
        padding-left: 12px;
        padding-right: 12px;
        border-left-width: 3px;
    }

    body.sidebar-collapsed .sidebar-link.active {
        padding-left: 9px;
        box-shadow: none;
    }

    body.sidebar-collapsed .sidebar-section-label {
        padding: 4px 10px 8px;
        height: auto;
    }

    body.sidebar-collapsed .sidebar-item.has-active-child > .sidebar-link::after {
        display: none;
    }

    body.sidebar-collapsed .sidebar-submenu {
        max-height: none;
    }

    body.sidebar-collapsed .sidebar-link > .badge-notify {
        position: static;
        min-width: 20px;
        padding: 2px 6px;
        font-size: .68rem;
    }

    /* La marca aparece porque el logo del sidebar no se ve */
    .topbar-brand {
        display: flex;
    }

    /* El titulo cede el espacio a la marca */
    .topbar-title {
        display: none;
    }

    .content-wrapper {
        padding: 16px;
    }

    /* Los tooltips no tienen sentido sin modo colapsado */
    .sidebar-tooltip {
        display: none;
    }
}

@media (max-width: 767.98px) {

    .topbar {
        padding: 0 12px;
        gap: 8px;
    }

    /* El usuario queda reducido al avatar */
    .topbar-user-meta,
    .topbar-user-caret {
        display: none;
    }

    .topbar-user-trigger {
        padding: 4px;
    }

    body.has-sidebar .alert-container {
        width: 90%;
    }
}

@media (max-width: 575.98px) {

    .topbar-brand-text {
        display: none;
    }

    .content-wrapper {
        padding: 12px;
    }
}

/* ============================================================================
   16. CHROME SIN SIDEBAR
   Login, Registro, error fatal: no hay menu que mostrar, asi que el chrome se
   reduce a la topbar y el documento recupera su scroll. El layout ya marca el
   body como "no-sidebar" en servidor, de modo que no hay parpadeo.
   ============================================================================ */

/* Sin sidebar (por ejemplo si el partial no se pudo renderizar): el JS marca
   el body y aqui se devuelve el scroll al documento. */
body.no-sidebar {
    height: auto;
    overflow: visible;
}

body.no-sidebar .main-content {
    height: auto;
    margin-left: 0;
}

body.no-sidebar .content-wrapper {
    overflow: visible;
}

/* ============================================================================
   15. COMPLEMENTOS
   ============================================================================ */

/* Link plano de la topbar: "Salir" / "Iniciar Sesion" cuando no hay dropdown
   de usuario (sesion de prueba, error fatal, sin autenticar). */
.topbar-plain-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    transition: background .18s ease, color .18s ease;
}

.topbar-plain-link,
.topbar-plain-link:link,
.topbar-plain-link:visited {
    color: #4b5563 !important;
    text-decoration: none !important;
}

.topbar-plain-link:hover,
.topbar-plain-link:focus {
    background: #f1f4f8;
    color: var(--sidebar-bg) !important;
    text-decoration: none !important;
}

/* Bootstrap pinta un outline en button:focus tambien al hacer click con el
   mouse. Se quita aqui y lo devuelven las reglas :focus-visible de arriba,
   que tienen mas especificidad. */
body .sidebar button:focus,
body .topbar button:focus,
body .confirm-modal button:focus {
    outline: none;
}

/* La topbar ocupa todo el ancho y la marca toma el lugar de la hamburguesa,
   que aqui no tendria nada que plegar. */
body.no-sidebar .topbar-toggle {
    display: none;
}

body.no-sidebar .topbar-brand {
    display: flex;
}

body.no-sidebar .topbar-title {
    display: none;
}

body.no-sidebar .content-wrapper {
    padding: 0;
}

/* --- Topbar de login, calcada de SIEC y Soporte ---------------------------
   Barra del color del tema (no blanca), 56px de alto, la marca a la izquierda
   y el acceso a la derecha como boton delineado. */
body.no-sidebar .topbar {
    height: 56px;
    padding: 0 22px;
    background: var(--sidebar-bg);
    border-bottom: 0;
    box-shadow: 0 1px 4px rgba(16, 24, 40, .18);
}

body.no-sidebar .topbar-brand,
body.no-sidebar .topbar-brand:hover,
body.no-sidebar .topbar-brand:focus {
    gap: 10px;
    color: #fff;
}

body.no-sidebar .topbar-brand-text {
    display: inline;
    font-size: 1.15rem;
    font-weight: 700;
}

/* El logo va suelto sobre la barra, sin recuadro: el PNG ya trae sus propios
   colores y el fondo claro solo lo ensanchaba. */
body.no-sidebar .topbar-brand > img {
    width: auto;
    height: 36px;
    /* Holgado para no recortar un logo apaisado; la barra mide 56px, asi que
       quedan 10px de aire arriba y abajo. */
    max-width: 48px;
    padding: 0;
    object-fit: contain;
    background: none;
    border-radius: 0;
}

/* .topbar-title esta oculto aqui, asi que ya no queda ningun elemento elastico
   que empuje: el bloque de acciones se ancla a la derecha por su cuenta. */
body.no-sidebar .topbar-actions {
    margin-left: auto;
}

body.no-sidebar .topbar-plain-link {
    padding: 7px 16px;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 4px;
    font-size: .9rem;
    font-weight: 500;
}

body.no-sidebar .topbar-plain-link,
body.no-sidebar .topbar-plain-link:link,
body.no-sidebar .topbar-plain-link:visited {
    color: #fff !important;
}

body.no-sidebar .topbar-plain-link:hover,
body.no-sidebar .topbar-plain-link:focus {
    background: rgba(255, 255, 255, .16);
    color: #fff !important;
}
