/* =============================================================================
 * TechnoSense-Caelum — nav.css · COPIA FIEL de TechnoSense-Wx (2026-11-04).
 * No se edita aquí: el estilo de la familia se copia tal cual (CLAUDE.md). Lo
 * propio de Caelum va en modules/panel.css.
 * -----------------------------------------------------------------------------
 * Header compartido + sidebar de navegación lateral.
 * Depende de theme.css y base.css.
 *
 * Orden de carga: theme.css → base.css → components.css → nav.css → módulo.css
 * ============================================================================= */

/* ── App Header ──────────────────────────────────────────────────────────────*/
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--fs-xs);
    color: var(--muted);
}

/* Brand */
.app-brand {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: var(--fw-black);
    color: var(--sky-900);
    letter-spacing: -0.02em;
    user-select: none;
}
.app-brand .brand-wx,
.brand-wx { color: var(--solar-500); }

/* Timer y signout en header */
.nav-timer  { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.nav-signout {
    color: var(--muted);
    font-size: var(--fs-xs);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--t-fast);
}
.nav-signout:hover { color: var(--ink); }

/* ── Hamburger ───────────────────────────────────────────────────────────────*/
.nav-hamburger {
    width: 36px;
    height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--r-sm);
    padding: 0;
    transition: background var(--t-fast);
    flex-shrink: 0;
}
.nav-hamburger:hover { background: var(--sky-100); }

.nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--ink-soft);
    border-radius: 2px;
    transition: transform var(--t-base), opacity var(--t-base), width var(--t-base);
    transform-origin: center;
}

/* Animación hamburger → X cuando el nav está abierto */
.nav-open .nav-hamburger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-open .nav-hamburger span:nth-child(2) {
    opacity: 0;
    width: 0;
}
.nav-open .nav-hamburger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── Overlay ─────────────────────────────────────────────────────────────────*/
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 74, 110, 0.35);
    backdrop-filter: blur(2px);
    z-index: 299;
    opacity: 0;
    transition: opacity var(--t-base);
}
.nav-overlay.open {
    display: block;
    opacity: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────*/
.nav-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    background: var(--white);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    /* Línea de acento lateral — firma del sistema */
    border-left: 3px solid transparent;
    background-clip: padding-box;
}
.nav-sidebar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--sky-600), var(--solar-500));
}
.nav-sidebar.open {
    transform: translateX(0);
}

/* Cabecera del sidebar */
.nav-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.nav-sidebar-brand {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: var(--fw-black);
    color: var(--sky-900);
    letter-spacing: -0.02em;
}
.nav-sidebar-brand span { color: var(--solar-500); }

.nav-sidebar-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    border-radius: var(--r-sm);
    transition: background var(--t-fast), color var(--t-fast);
    padding: 0;
}
.nav-sidebar-close:hover {
    background: var(--paper);
    color: var(--ink);
}

/* ── Secciones de nav ────────────────────────────────────────────────────────*/
.nav-section {
    padding: 0.75rem 0.75rem 0.25rem;
    flex-shrink: 0;
}
/* La sección bottom se pega al final */
.nav-section-bottom {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 0.75rem;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: var(--fw-bold);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.5rem;
    margin-bottom: 0.4rem;
}

/* ── Ítems de navegación ─────────────────────────────────────────────────────*/
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-soft);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    cursor: pointer;
    margin-bottom: 0.15rem;
}
.nav-item:hover {
    background: var(--sky-100);
    color: var(--sky-900);
}
.nav-item.active {
    background: var(--sky-100);
    color: var(--sky-700);
    font-weight: var(--fw-bold);
}
.nav-item.active .nav-icon {
    stroke: var(--sky-600);
}
/* Ítem de peligro (sign out) */
.nav-item-danger { color: var(--muted); }
.nav-item-danger:hover {
    background: rgba(220, 38, 38, 0.06);
    color: var(--error);
}
.nav-item-danger:hover .nav-icon {
    stroke: var(--error);
}

/* Ícono SVG dentro del nav-item */
.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    stroke: var(--muted);
    transition: stroke var(--t-fast);
}
.nav-item:hover .nav-icon {
    stroke: var(--sky-600);
}

/* ── Dot live (pulsante) ─────────────────────────────────────────────────────*/
/* Reutiliza el mismo de dashboard.css si ya está cargado,
   se define aquí para que funcione en cualquier página */
.dot-live {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    display: inline-block;
    flex-shrink: 0;
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ── Body con nav abierto: prevenir scroll ───────────────────────────────────*/
body.nav-open {
    overflow: hidden;
}

/* ── Responsive ──────────────────────────────────────────────────────────────*/
/* La cabecera en un teléfono (visto el 2026-10-01 a 390px): el wordmark partía
   en dos líneas, «updates in 38s» en otras dos, y «Sign out» salía cortado,
   porque ninguna pieza encoge y entre todas sumaban ~530px. Lo que se hace:
   el contador desaparece (el punto verde sigue diciendo que está vivo), el
   enlace de salir no se pinta (salir queda en el menú desplegable, sección
   Cuenta), el wordmark no parte, y los huecos se estrechan. A 375px suma
   ~330. */
@media (max-width: 640px) {
    .nav-sidebar { width: 85vw; max-width: 300px; }

    .app-header { padding: 0 0.75rem; }
    .app-header-left, .app-header-right { gap: 0.5rem; }
    .app-brand { white-space: nowrap; font-size: 1rem; }
    .nav-timer   { display: none; }
    .nav-signout { display: none; }
}
/* Teléfonos de 320–360 px: un poco más apretado todavía. `.app-header-right`
   delante porque dashboard.css redefine .dot-live después de esta hoja. */
@media (max-width: 360px) {
    .app-header { padding: 0 0.5rem; }
    .app-header-left, .app-header-right { gap: 0.35rem; }
    .app-brand { font-size: 0.9rem; }
    .app-header-right .dot-live { display: none; }
}



/* ── Grupos de módulos con sub-items anidados ────────────────────────────────*/
.nav-group {
    margin-bottom: 0.35rem;
}
/* Encabezado del módulo: ícono + nombre (no clickable) */
.nav-group-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem 0.3rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--ink);
    user-select: none;
}
.nav-group-head .nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    stroke: var(--sky-600);
}

/* Contenedor de sub-items: indentado bajo el encabezado */
.nav-subitems {
    display: flex;
    flex-direction: column;
    padding-left: 0.9rem;
    margin-left: 0.55rem;
    border-left: 1.5px solid var(--line);
}

/* Sub-item (Dashboard / Historical Data) */
.nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-soft);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    margin-bottom: 0.1rem;
}
.nav-subitem:hover {
    background: var(--sky-100);
    color: var(--sky-900);
}
.nav-subitem.active {
    background: var(--sky-100);
    color: var(--sky-700);
    font-weight: var(--fw-bold);
}
.nav-subicon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke: var(--muted);
    transition: stroke var(--t-fast);
}
.nav-subitem:hover .nav-subicon,
.nav-subitem.active .nav-subicon {
    stroke: var(--sky-600);
}


/* ══════════════════════════════════════════════════════════════════════════════
 * TEMA OSCURO — header, sidebar, toggle
 * ══════════════════════════════════════════════════════════════════════════════ */

/* ── Botón de toggle sol/luna ────────────────────────────────────────────── */
/* ── Switch de idioma EN|ES (hermano del toggle de tema) ─────────────────── */
.lang-toggle {
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-3, #f1f5f9);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}
.lang-toggle .lang-opt {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--muted);
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1;
    transition: background var(--t-fast), color var(--t-fast);
}
.lang-toggle .lang-opt.active {
    background: var(--sky-600);
    color: #fff;
}
.lang-toggle:hover .lang-opt:not(.active) { color: var(--ink-soft); }
[data-theme="dark"] .lang-toggle { background: var(--surface-1); border-color: var(--line); }

.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background var(--t-fast), color var(--t-fast);
    flex-shrink: 0;
    position: relative;
}
.theme-toggle:hover {
    background: var(--sky-100);
    color: var(--sky-700);
}

/* Sol visible en claro, Luna en oscuro */
.theme-icon-sun  { display: block; }
.theme-icon-moon { display: none; }

[data-theme="dark"] .theme-icon-sun  { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }

/* ── Header oscuro ──────────────────────────────────────────────────────── */
[data-theme="dark"] .app-header {
    background: var(--surface-1);
    border-bottom-color: var(--line);
}
[data-theme="dark"] .app-brand { color: var(--ink); }
[data-theme="dark"] .brand-wx  { color: var(--sky-600); }
[data-theme="dark"] .nav-timer { color: var(--muted); }
[data-theme="dark"] .nav-signout { color: var(--muted); }
[data-theme="dark"] .nav-signout:hover { color: var(--ink); }
[data-theme="dark"] .dot-live { background: var(--ok); }

/* ── Hamburger oscuro ───────────────────────────────────────────────────── */
[data-theme="dark"] .nav-hamburger span { background: var(--muted); }
[data-theme="dark"] .nav-hamburger:hover span { background: var(--ink); }

/* ── Sidebar oscuro ─────────────────────────────────────────────────────── */
[data-theme="dark"] .nav-sidebar {
    background: var(--surface-1);
    border-right-color: var(--line);
}
[data-theme="dark"] .nav-sidebar-head {
    border-bottom-color: var(--line);
}
[data-theme="dark"] .nav-sidebar-brand { color: var(--ink); }
[data-theme="dark"] .nav-sidebar-brand span { color: var(--sky-600); }
[data-theme="dark"] .nav-sidebar-close { color: var(--muted); }
[data-theme="dark"] .nav-sidebar-close:hover { background: var(--surface-3); color: var(--ink); }

[data-theme="dark"] .nav-section-label { color: var(--muted); }
[data-theme="dark"] .nav-item { color: var(--ink-soft); }
[data-theme="dark"] .nav-item:hover {
    background: var(--surface-3);
    color: var(--ink);
}
[data-theme="dark"] .nav-item.active {
    background: var(--sky-100);
    color: var(--sky-600);
}
[data-theme="dark"] .nav-icon { stroke: currentColor; }
[data-theme="dark"] .nav-overlay { background: rgba(0,0,0,0.6); }

/* ── Toggle tema en sidebar también ─────────────────────────────────────── */
[data-theme="dark"] .theme-toggle:hover {
    background: var(--surface-3);
    color: var(--sky-600);
}
/* ── Grupos de módulos anidados — tema oscuro ────────────────────────────────*/
[data-theme="dark"] .nav-group-head { color: var(--ink); }
[data-theme="dark"] .nav-group-head .nav-icon { stroke: var(--sky-600); }
[data-theme="dark"] .nav-subitems { border-left-color: var(--line); }
[data-theme="dark"] .nav-subitem { color: var(--ink-soft); }
[data-theme="dark"] .nav-subitem:hover {
    background: var(--surface-3);
    color: var(--ink);
}
[data-theme="dark"] .nav-subitem.active {
    background: var(--sky-100);
    color: var(--sky-600);
}
[data-theme="dark"] .nav-subicon { stroke: var(--muted); }
[data-theme="dark"] .nav-subitem:hover .nav-subicon,
[data-theme="dark"] .nav-subitem.active .nav-subicon { stroke: var(--sky-600); }