/* ═══════════════════════════════════════════════════════════════
   nexus-layout.css — Estilos globales del layout de Nexus SIMPLE
   Usa CSS custom properties — los temas sobreescriben desde [data-skin].
   Nexus SIMPLE — 2026
════════════════════════════════════════════════════════════════ */

/* ── TOKENS DE COLOR (tema claro = default) ── */
:root {
    color-scheme: light;

    /* Superficies */
    --nx-body-bg:         #BED6F7;
    --nx-work-bg:         #FFFFFF;
    --nx-work-border:     #99BBE8;
    --nx-panel-bg:        #FFFFFF;
    --nx-popup-bg:        #F0F5FD;

    /* Header */
    --nx-hdr-c1:          #E3EFFF;
    --nx-hdr-c2:          #B5D3FF;
    --nx-hdr-c3:          #90B8FF;
    --nx-hdr-c4:          #A1C7FF;
    --nx-hdr-border:      #7185AB;
    --nx-hdr-inset:       rgba(255,255,255,0.9);
    --nx-hdr-tshadow:     0 1px 0 rgba(255,255,255,0.8);

    /* Texto / marca */
    --nx-brand:           #15428B;
    --nx-brand-dk:        #0D3482;
    --nx-muted:           #4b646f;
    --nx-text:            #111111;

    /* Bordes */
    --nx-border-md:       #7185AB;
    --nx-border-lt:       #99BBE8;
    --nx-border-vlt:      #C5D9F0;
    --nx-sep:             #C5D9F0;

    /* Sidebar */
    --nx-sidebar-c1:      #DFE9F5;
    --nx-sidebar-c2:      #D3E0F1;
    --nx-sidebar-border:  #99BBE8;
    --nx-menu-bg:         #FFFFFF;
    --nx-menu-sep:        #F0F5FD;
    --nx-mod-hdr-c1:      #C5D9F0;
    --nx-mod-hdr-c2:      #A8C5E8;
    --nx-grp-hdr-bg:      #E3EFFF;
    --nx-sublink-bg:      #E8F1FB;
    --nx-submenu-bg:      #FAFCFF;

    /* Hover accent (amarillo) */
    --nx-hover:           #FFE88C;
    --nx-hover-text:      #000000;

    /* Inputs */
    --nx-inp-bg:          #FFFFFF;
    --nx-inp-border:      #ABC1DE;
    --nx-inp-dis-bg:      #F8F9FA;
    --nx-inp-ro-bg:       #F0F5FD;
    --nx-inp-text:        inherit;

    /* Cabeceras de panel/frame */
    --nx-fhdr-c1:         #E3EFFF;
    --nx-fhdr-c2:         #C5D9F0;

    /* Ribbon / botones */
    --nx-ribbon-c1:       #DDE9F8;
    --nx-ribbon-c2:       #C2D6F0;
    --nx-btn-c1:          #F5F9FF;
    --nx-btn-c2:          #DDE9F8;
    --nx-btn-text:        #15428B;
    --nx-btn-border:      #7185AB;

    /* Pestañas */
    --nx-tab-c1:          #F0F5FF;
    --nx-tab-c2:          #D0E1F7;
    --nx-tab-border:      #99BBE8;
    --nx-tab-text:        #15428B;
    --nx-tab-active-bg:   #FFFFFF;
    --nx-tab-panel-bg:    #FFFFFF;
    --nx-tab-marker:      #F9BB00;

    /* Scrollbars Chromium */
    --nx-scroll-track:    #D3E0F1;
    --nx-scroll-thumb:    #99BBE8;

    /* Welcome bar (dashboard) */
    --nx-welcome-bg1:     #2255A4;
    --nx-welcome-bg2:     #4A7CC7;
    --nx-welcome-bg3:     #6FA3E0;
    --nx-welcome-border:  #1a4080;
    --nx-welcome-text:    #FFFFFF;
    --nx-welcome-sub:     #C8DEFF;
}

/* ═══ REGLAS DE LAYOUT ═══════════════════════════════════════════ */

body {
    background-color: var(--nx-body-bg);
    color: var(--nx-text);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    margin: 0; display: flex; flex-direction: column; overflow: hidden;
    /* 100vh en mobile incluye el espacio de la barra de direcciones/gestos de
       Android, que en la práctica no es visible — eso recortaba contenido
       (ej. el link de Cerrar Sesión) cuando el navegador no está en pantalla
       completa. 100dvh mide el viewport real; --nx-vh (JS, ver main.php) es
       la posta en navegadores que no recalculan 100dvh solo al entrar/salir
       de pantalla completa (botón Maximizar) o al mostrar/ocultar su propia
       barra (Samsung Internet). El 100vh/100dvh de arriba quedan de fallback. */
    height: 100vh; height: 100dvh; height: var(--nx-vh, 100dvh);
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar       { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--nx-scroll-track); }
::-webkit-scrollbar-thumb { background: var(--nx-scroll-thumb); border-radius: 3px; }


/* ── HEADER ── */
.office-header {
    background: linear-gradient(to bottom,
        var(--nx-hdr-c1) 0%, var(--nx-hdr-c2) 50%,
        var(--nx-hdr-c3) 51%, var(--nx-hdr-c4) 100%);
    height: 50px; border-bottom: 1px solid var(--nx-hdr-border);
    display: flex; justify-content: space-between; align-items: center; padding: 0 0 0 10px;
    box-shadow: inset 0 1px 0 var(--nx-hdr-inset);
    flex-shrink: 0; position: relative; z-index: 1000;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.brand-text   { color: var(--nx-brand); font-size: 18px; font-weight: bold; text-shadow: var(--nx-hdr-tshadow); }

/* ── HAMBURGUESA ── */
.hamburger-btn {
    background: none; border: 1px solid transparent; border-radius: 3px;
    padding: 7px 8px; cursor: pointer;
    display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.3); border-color: var(--nx-hdr-border); }
.hamburger-btn span  { display: block; width: 20px; height: 2px; background: var(--nx-brand); border-radius: 1px; }

/* ── HEADER DERECHO ── */
.header-right { display: flex; align-items: stretch; height: 100%; }

/* ── AVATAR ── */
.user-widget { position: relative; display: flex; align-items: center; }
.user-avatar-btn {
    display: flex; align-items: center; gap: 8px;
    color: var(--nx-brand); font-size: 13px; font-weight: bold;
    padding: 4px 8px; border-radius: 3px; border: 1px solid transparent;
    cursor: pointer; background: none; height: 100%;
}
.user-avatar-btn:hover { background: rgba(255,255,255,0.3); border-color: var(--nx-hdr-border); }
.user-avatar-circle {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(to bottom, #4A7CC7, #2255A4);
    border: 2px solid rgba(255,255,255,0.6); box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    display: inline-flex; align-items: center; justify-content: center;
    color: #FFF; font-size: 15px; font-weight: bold; flex-shrink: 0;
}
.user-name-text { text-shadow: var(--nx-hdr-tshadow); }
.caret-ico {
    display: inline-block; width: 0; height: 0; margin-left: 4px;
    border-left: 4px solid transparent; border-right: 4px solid transparent;
    border-top: 5px solid var(--nx-brand); vertical-align: middle;
}

/* ── MENÚ DE USUARIO ── */
.user-menu {
    display: none; position: absolute; right: 0; top: 50px;
    min-width: 195px; z-index: 9999;
    list-style: none; margin: 0; padding: 4px 0;
    background: var(--nx-popup-bg); border: 1px solid var(--nx-border-md); border-radius: 4px;
    box-shadow: 2px 4px 10px rgba(0,0,0,0.3);
}
.user-widget.open .user-menu { display: block; }
.um-header {
    padding: 7px 14px; background: var(--nx-grp-hdr-bg);
    border-bottom: 1px solid var(--nx-sep);
    font-size: 11px; font-weight: bold; color: var(--nx-muted); white-space: nowrap;
}
.um-sep { height: 1px; background: var(--nx-sep); margin: 3px 0; }
.user-menu li > a,
.user-menu li > span.um-disabled { display: block; padding: 7px 14px; font-size: 12px; text-decoration: none; }
.user-menu li > a              { color: var(--nx-brand); }
.user-menu li > a:hover        { background: var(--nx-hover); color: var(--nx-hover-text); }
.user-menu li > a .fa,
.user-menu li > span.um-disabled .fa { width: 16px; margin-right: 6px; }
.user-menu li > span.um-disabled { color: #888; cursor: default; }
.um-danger > a       { color: #c0392b !important; }
.um-danger > a:hover { background: var(--nx-hover); }

/* ── CONTROLES DE VENTANA ── */
.win-controls { display: flex; align-items: stretch; border-left: 1px solid var(--nx-hdr-border); margin-left: 4px; }
.win-btn {
    width: 34px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: none; border-left: 1px solid rgba(255,255,255,0.2);
    background: transparent; color: var(--nx-brand); font-size: 14px;
    font-family: 'Segoe UI Symbol', 'Arial Unicode MS', sans-serif;
    transition: background 0.12s; padding: 0;
}
.win-btn:hover { background: rgba(255,255,255,0.3); }
.win-btn-close:hover { background: linear-gradient(to bottom, #FF6055, #C00000) !important; color: #FFF !important; }

@media (max-width: 600px) {
    .office-header { padding: 0 6px 0 6px; }
    .header-left   { gap: 6px; }
    .win-btn       { width: 30px; font-size: 13px; }
    /* En mobile no entraba todo el header y el botón de Cerrar Sesión quedaba
       fuera de pantalla (había que deslizar para verlo) — se achica el widget
       de usuario a sólo el ícono, sin nombre ni flechita de menú. */
    .user-name-text, .caret-ico { display: none; }
    .user-avatar-btn { padding: 4px 6px; gap: 0; }
}

/* ── LAYOUT ── */
.main-container { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ── */
.office-sidebar {
    width: 220px; min-width: 220px;
    background: linear-gradient(to right, var(--nx-sidebar-c1), var(--nx-sidebar-c2));
    border-right: 1px solid var(--nx-sidebar-border);
    overflow-y: auto; overflow-x: hidden; padding: 6px;
    transition: width 0.22s ease, min-width 0.22s ease, padding 0.22s ease;
}
.office-sidebar.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; }

/* ── ALERTA VENCIMIENTO ── */
.alert-vencimiento {
    background: linear-gradient(to bottom, #FFF9D7 0%, #FFEFAB 100%);
    border: 1px solid #E2C822; border-radius: 4px;
    padding: 10px 15px; margin-bottom: 15px;
    color: #6D5B00; font-size: 13px; display: flex; align-items: center; gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.alert-vencimiento i { font-size: 18px; color: #E2C822; }

/* ── MÓDULOS (SIDEBAR) ── */
.mod-panel   { border: 1px solid var(--nx-border-lt); border-radius: 4px; margin-bottom: 5px; background: var(--nx-menu-bg); overflow: hidden; }
.mod-heading { background: linear-gradient(to bottom, var(--nx-mod-hdr-c1), var(--nx-mod-hdr-c2)); padding: 0; }
.mod-heading > a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; color: var(--nx-brand-dk); font-size: 12px; font-weight: bold;
    text-decoration: none; text-transform: uppercase; letter-spacing: 0.5px;
}
.mod-heading > a:hover { background: rgba(255,255,255,0.15); }
.grp-heading { background: var(--nx-grp-hdr-bg); border-bottom: 1px solid var(--nx-border-vlt); border-top: 1px solid var(--nx-border-vlt); padding: 0; }
.grp-heading > a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 12px; color: var(--nx-brand); font-size: 10px; font-weight: bold;
    text-decoration: none; text-transform: uppercase; letter-spacing: 0.4px;
}
.grp-heading > a:hover { background: rgba(255,255,255,0.25); }
.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-list > li > a {
    display: block; padding: 5px 16px 5px 20px; color: var(--nx-brand);
    font-size: 11px; text-decoration: none;
    border-bottom: 1px solid var(--nx-menu-sep); white-space: nowrap;
}
.menu-list > li > a:hover { background: var(--nx-hover); color: var(--nx-hover-text); }
.menu-list > li > a i,
.menu-list > li > a .fa-solid { margin-right: 4px; }
/* Link activo (módulo actualmente abierto) */
.menu-list > li > a.nx-active,
.submenu-list > li > a.nx-active {
    background: var(--nx-hover); color: var(--nx-hover-text);
    font-weight: bold; border-left: 3px solid var(--nx-tab-marker);
}
.nx-collapse          { display: none; }
.nx-collapse.nx-open  { display: block; }
.nx-caret             { display: inline-block; transition: transform 0.2s; transform: rotate(-90deg); }
.nx-toggle.nx-open .nx-caret { transform: rotate(0deg); }

/* ── SUB-HEADING (nivel 3b) ── */
a.sub-heading {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 10px 5px 24px; color: var(--nx-brand); font-size: 11px; font-weight: bold;
    text-decoration: none; background: var(--nx-sublink-bg);
    border-bottom: 1px solid var(--nx-border-vlt); border-left: 3px solid var(--nx-border-md);
    white-space: nowrap;
}
a.sub-heading:hover { background: var(--nx-hover); color: var(--nx-hover-text); }

/* ── SUBMENU-LIST (nivel 4) ── */
.submenu-list { list-style: none; padding: 0; margin: 0; }
.submenu-list > li > a {
    display: block; padding: 4px 14px 4px 20px;
    color: var(--nx-brand); font-size: 11px; text-decoration: none;
    border-bottom: 1px solid var(--nx-menu-sep); background: var(--nx-submenu-bg); white-space: nowrap;
}
.submenu-list > li > a:hover { background: var(--nx-hover); color: var(--nx-hover-text); }
.submenu-list > li > a .fa-solid { color: var(--nx-brand); margin-right: 5px; }

/* ── BOTÓN HOME ── */
.home-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 3px;
    color: var(--nx-brand); font-size: 17px; text-decoration: none;
    border: 1px solid transparent; transition: background .12s;
}
.home-btn:hover { background: rgba(255,255,255,0.3); border-color: var(--nx-hdr-border); color: var(--nx-brand); text-decoration: none; }

/* ── MESSAGEBOX NEXUS ── */
.nx-msg-btn {
    background: linear-gradient(to bottom, var(--nx-btn-c1), var(--nx-btn-c2));
    border: 1px solid var(--nx-btn-border); color: var(--nx-btn-text);
    padding: 5px 22px; font-size: 12px; font-weight: bold;
    border-radius: 2px; cursor: pointer; min-width: 76px; font-family: inherit;
    transition: background .12s;
}
.nx-msg-btn:hover        { background: linear-gradient(to bottom,#FFE88C,#FFD700); border-color:#C8A800; color:#000; }
.nx-msg-btn-ok           { background: linear-gradient(to bottom,#4A7CC7,#2255A4); color:#FFF; border-color:#1A3A8A; }
.nx-msg-btn-ok:hover     { background: linear-gradient(to bottom,#5586D7,#2B63B8); border-color:#1A3A8A; color:#FFF; }
.nx-msg-btn-danger       { background: linear-gradient(to bottom,#FFEBEE,#FFCDD2); color:#B71C1C; border-color:#E57373; }
.nx-msg-btn-danger:hover { background: linear-gradient(to bottom,#FFCDD2,#EF9A9A); border-color:#C62828; }

/* ── ÁREA DE TRABAJO ── */
.work-area {
    flex: 1; background: var(--nx-work-bg); margin: 8px;
    border: 1px solid var(--nx-work-border); border-radius: 4px;
    overflow-y: auto; padding: 20px; color: var(--nx-text);
    position: relative;  /* necesario para nx-preview y nx-close-btn */
}

/* ══════════════════════════════════════════════════════════════
   PAGEFRAME — sistema de pestañas con iframes
   Dashboard siempre inline; módulos en pestañas/iframes.
══════════════════════════════════════════════════════════════ */

/* Body dentro del iframe (modo embedded) */
.nx-embedded-body {
    /* Anula el flex/overflow del selector body{} de nexus-layout.css */
    display: block !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100vh; min-height: 100dvh;
    /* Padding igual que work-area para respiración visual consistente */
    padding: 16px !important;
    background: var(--nx-work-bg);
    box-sizing: border-box;
}

/* Contenedor principal de pestañas */
.nx-tabframe-area {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Dashboard — iframe permanente, visible cuando no hay módulos abiertos */
.nx-dashboard-frame {
    flex: 1;
    min-height: 0;
    border: none;
    width: 100%;
    background: var(--nx-work-bg);
    /* visible por defecto — JS lo oculta cuando abren módulos */
}

/* ── Barra de pestañas ── */
.nx-tabbar {
    flex-shrink: 0;
    background: var(--nx-grp-hdr-bg);
    border-bottom: 1px solid var(--nx-tab-border);
    padding: 3px 5px 0 5px;
    min-height: 30px;
}
.nx-tabbar-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0;
    scrollbar-width: thin;
}
.nx-tabbar-tabs::-webkit-scrollbar { height: 4px; }

/* Botón de pestaña — mismo estilo que .tab-link de nexus-common.css */
.nx-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 16px;
    cursor: pointer;
    background: linear-gradient(to bottom, var(--nx-tab-c1), var(--nx-tab-c2));
    border: 1px solid var(--nx-tab-border);
    border-bottom: none;
    margin-right: 2px;
    color: var(--nx-tab-text);
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
    transition: background .15s;
    white-space: nowrap;
    user-select: none;
    position: relative;
    bottom: -1px;   /* solapa la línea inferior del tabbar */
}
.nx-tab-btn:hover:not(.active) { background: var(--nx-hover); color: var(--nx-hover-text); }
.nx-tab-btn.active {
    background: var(--nx-tab-active-bg);
    color: var(--nx-text);
    border-top: 2px solid var(--nx-tab-marker);  /* barra dorada igual que ABM */
    border-bottom: 2px solid var(--nx-tab-active-bg);
    z-index: 1;
}

.nx-tab-label { pointer-events: none; }

/* Botón X de cierre — cuadrado rojo igual a .nx-close-btn */
.nx-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: linear-gradient(to bottom, #FF7070 0%, #C0392B 50%, #A93226 100%);
    border: 1px solid #7B241C;
    border-radius: 2px;
    color: #FFF;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: -1px 1px 2px rgba(0,0,0,.25);
    transition: background .1s;
    pointer-events: auto;
    line-height: 1;
}
.nx-tab-close:hover  { background: linear-gradient(to bottom, #FF9090, #E74C3C); }
.nx-tab-close:active { background: linear-gradient(to bottom, #C0392B, #A93226); }

/* ── Barra de progreso de carga de módulo (indeterminada) ──
   Debajo de la barra de pestañas, ancho completo del workspace — se
   muestra mientras el iframe de una pestaña recién abierta todavía está
   cargando su módulo (ver main.php, _mostrarBarraCarga/_ocultarBarraCarga). */
.nx-tab-loading-bar {
    flex-shrink: 0;
    height: 3px;
    width: 100%;
    background: var(--nx-tab-border);
    overflow: hidden;
    position: relative;
}
.nx-tab-loading-bar[hidden] { display: none; }
.nx-tab-loading-bar::after {
    content: '';
    position: absolute;
    top: 0; left: -35%;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, var(--nx-brand), var(--nx-tab-marker));
    animation: nxTabLoadingSlide 1.1s ease-in-out infinite;
}
@keyframes nxTabLoadingSlide {
    0%   { left: -35%; }
    50%  { left: 55%; }
    100% { left: 110%; }
}

/* ── Área de contenido (iframes) ── */
.nx-tabs-content {
    flex: 1;
    min-height: 0;   /* crítico: permite que flex encoja el hijo */
    overflow: hidden;
    position: relative;
    background: var(--nx-work-bg);
}
.nx-tab-iframe {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    background: var(--nx-work-bg);
}

/* ══════════════════════════════════════════════════════════════
   GRILLA A PANTALLA COMPLETA — patrón compartido, un solo lugar
   ══════════════════════════════════════════════════════════════
   Creado 09-sep-2026 a partir de Ventas Rápidas (pedido real de
   guillermo.bigolin: el buscador incremental quedaba oculto detrás de la
   barra de opciones inferior cuando la grilla crecía). Cualquier módulo con
   una grilla de ítems (Facturas, Remitos, Presupuestos, Rastreo, NC/ND,
   etc.) puede sumarse a este layout SIN repetir la lógica de flexbox:

   1) JS, apenas arranca el módulo (antes de que el usuario pueda cargar
      líneas): document.body.classList.add('nx-fullscreen-grid');
   2) Marcar con .nx-fs-fixed los bloques que NO deben crecer/encogerse
      (headers, tabs, barras de acciones, totales, avisos, etc.)
   3) Marcar con .nx-fs-fill cada contenedor INTERMEDIO entre el body y la
      grilla (para que el alto disponible se transmita hacia abajo — sin
      esto en TODOS los niveles, el de más adentro no se encoge).
   4) Marcar con .nx-fs-scroll el contenedor final que realmente scrollea
      (la grilla de ítems) — reemplaza cualquier max-height fijo en línea.

   Si el módulo tiene pestañas y sólo UNA contiene la grilla (como en
   Ventas Rápidas/Facturas), esa pestaña puntual necesita su propia regla
   chica "cuando está activa, además de nx-fs-fill" — el id/clase de esa
   pestaña cambia por módulo, no se puede generalizar más que eso. Ver
   ejemplo real en Ventas Rápidas (style.css) y Facturas (view.php).

   Documentado en detalle en NEXUS_grilla_fullscreen_scroll.md. */
body.nx-fullscreen-grid.nx-embedded-body {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
}
body.nx-fullscreen-grid .nx-fs-fixed {
    flex: 0 0 auto;
}
body.nx-fullscreen-grid .nx-fs-fill {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
body.nx-fullscreen-grid .nx-fs-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto;
    overflow-x: auto;
}
