/* =========================================
   SISTEMA DE NAVEGACIÓN AI SMART CONTENT
   ========================================= */

/* Importar estilos base */
@import url('base.css');

/* Variables específicas para navegación */
:root {
    /* Width states (spec: expanded 260px, collapsed 51px) */
    --nav-width: 260px;
    --nav-width-collapsed: 51px;
    --nav-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-overlay: rgba(0, 0, 0, 0.8);
    --nav-bg: var(--bg-primary);
    --nav-border: var(--border-divider);
    --nav-separator: var(--border-divider);
    --nav-item-height: 44px;
    --nav-item-height-sub: 36px;
    --app-header-height: 45.8px;
    /* Design tokens sidebar (spec) */
    --sidebar-background: var(--bg-primary);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(255, 255, 255, 0.08);
    --sidebar-icon-color: var(--text-secondary);
    --sidebar-text-primary: var(--text-primary);
    --sidebar-text-secondary: var(--text-secondary);
}

/* =========================================
   HEADER PRINCIPAL
   ========================================= */

.main-header {
    position: fixed !important;
    top: 0 !important;
    left: var(--nav-width, 260px);
    right: 0;
    max-width: calc(100vw - var(--nav-width, 260px));
    background: transparent !important; /* 100% transparente */
    border-bottom: none !important;
    padding: 8px 16px;
    z-index: 1000 !important;
    box-shadow: none !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backdrop-filter: none !important;
    box-sizing: border-box;
}

/* Cuando el sidebar está colapsado */
.side-navigation.collapsed ~ * .main-header,
body.sidebar-collapsed .main-header,
#app-container .main-header {
    left: var(--nav-width-collapsed, 72px);
}

/* Asegurar que el header dentro de app-container también respete el sidebar */
#app-container .main-header {
    position: fixed !important;
    top: 0 !important;
    left: var(--nav-width, 260px);
    max-width: calc(100vw - var(--nav-width, 260px));
    background: transparent !important;
    z-index: 1000 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

body.sidebar-collapsed #app-container .main-header,
.side-navigation.collapsed ~ #app-container .main-header {
    left: var(--nav-width-collapsed, 72px);
    max-width: calc(100vw - var(--nav-width-collapsed, 72px));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1rem;
    /* Formato: [item, ruta] [tokens, user] */
}

/* =========================================
   ICONO TOGGLE SIDEBAR EN HEADER
   ========================================= */

.header-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.header-sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-sidebar-toggle i {
    font-size: 16px;
    font-weight: 900;
    font-style: normal;
    font-family: "Font Awesome 6 Free";
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   ZONA IZQUIERDA: ITEM Y RUTA
   Formato: [item toggle, ruta]
   ========================================= */

.header-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 12px;
}

.logo-section {
    display: flex;
    align-items: center;
}

.title-section {
    display: flex;
    align-items: center;
}

.title-section h1,
#headerRoute {
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    line-height: 1.2;
}

.header-context {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.header-context-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.header-section {
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
}

.header-separator {
    color: var(--text-muted);
    font-size: 0.938rem;
    font-weight: 400;
}

.header-active-object {
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-context-secondary {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================
   ZONA DERECHA: TOKENS Y USUARIO
   Formato: [tokens, user]
   ========================================= */

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    margin-left: auto;
    position: relative;
}

/* Tokens/Créditos */
.header-credits {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.header-credits-value {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
    white-space: nowrap;
}

/* Avatar del usuario */
.header-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s ease;
}

.avatar-circle:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.avatar-initials {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--nav-transition);
    position: relative;
}

.header-user:hover {
    background: var(--bg-hover);
}

/* Avatar del header quitado: no combina con la plataforma; solo se muestra el botón menú */
.header-user-avatar,
.user-avatar {
    display: none !important;
}

.header-user-initials {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-user-chevron {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--nav-transition);
    flex-shrink: 0;
}

.header-user-chevron:hover {
    color: var(--text-primary);
}

.header-user-chevron i {
    font-size: 10px;
}

/* Dropdown de usuario */
.header-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-floating);
    z-index: 1000;
    display: none;
    overflow: hidden;
    min-width: 180px;
}

.header-user-dropdown.open {
    display: block;
}

.header-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--nav-transition);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
}

.header-user-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-user-dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.header-user-dropdown-item.header-user-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.header-user-dropdown-item.header-user-logout:hover i {
    color: #ef4444;
}

/* Botón hamburguesa - solo móvil */
.hamburger-menu {
    display: none;
}

@media (max-width: 768px) {
    .hamburger-menu {
        display: flex;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
    transition: var(--nav-transition);
}

.hamburger-menu:hover {
        background: var(--bg-hover);
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--nav-transition);
    transform-origin: center;
}
    
    
    .main-header {
        padding: 8px 12px;
        height: 44px;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}
}

/* =========================================
   NAVEGACIÓN LATERAL
   ========================================= */

.nav-overlay {
    display: none;
}

.nav-overlay.active {
    display: none;
}

.side-navigation {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-width);
    height: 100vh;
    background: var(--nav-bg);
    /* backdrop-filter removido para mejor rendimiento */
    border-right: 1px solid var(--nav-border);
    z-index: 1002;
    transform: translateX(0);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.side-navigation.active {
    transform: translateX(0);
}

.side-navigation.collapsed {
    width: var(--nav-width-collapsed);
}

/* Centrar todos los iconos en collapsed (consumidor y desarrollador) */
.side-navigation.collapsed .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 6px;
    padding-right: 6px;
}

/* Quitar del flujo en colapsado para que el icono centre: nav-text tiene flex:1 y ocupaba espacio */
.side-navigation.collapsed .nav-text,
.side-navigation.collapsed .nav-section-title,
.side-navigation.collapsed .nav-profile-info,
.side-navigation.collapsed .nav-profile-chevron {
    display: none !important;
}

/* Carets no existen en collapsed: containers abren flyout */
.side-navigation.collapsed .nav-chevron {
    display: none;
}

.side-navigation.collapsed .nav-link,
.side-navigation.collapsed .nav-submenu-toggle {
    justify-content: center;
    padding: 0;
    position: relative;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 12px;
}

.side-navigation.collapsed .nav-icon {
    margin: 0;
}

/* Vertical spacing 12px entre ítems */
.side-navigation.collapsed .nav-menu .nav-item,
.side-navigation.collapsed .nav-menu .nav-group {
    margin-bottom: 12px;
}

.side-navigation.collapsed .nav-menu .nav-item:last-child,
.side-navigation.collapsed .nav-menu .nav-group:last-child {
    margin-bottom: 0;
}

/* Active en collapsed: barra izquierda + highlight sutil (no tarjeta gigante) */
.side-navigation.collapsed .nav-link.active,
.side-navigation.collapsed .nav-submenu-toggle.active {
    background: rgba(255, 255, 255, 0.06);
}

.side-navigation.collapsed .nav-link.active::before,
.side-navigation.collapsed .nav-submenu-toggle.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 0 2px 2px 0;
    opacity: 0.9;
}

/* Submenú inline no visible en collapsed (se usa flyout) */
.side-navigation.collapsed .nav-submenu {
    display: none !important;
}

/* =========================================
   CAPA SUPERIOR: IDENTIDAD + ORGANIZACIÓN
   ========================================= */

/* =========================================
   CAPA 1 — CONTEXTO (Identidad de espacio)
   Responde: "¿En qué espacio estoy trabajando ahora?"
   ========================================= */

.nav-identity-section {
    position: relative;
    padding: 16px;
    border-bottom: 1px solid var(--nav-separator);
    /* Espacio real antes del menú principal */
    margin-bottom: 20px;
    background: var(--nav-bg);
}

.nav-identity-card {
    background: var(--bg-hover); /* Fondo ligeramente elevado */
    border: 1px solid var(--border-divider);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: var(--nav-transition);
}

.nav-identity-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-divider);
}

.nav-identity-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nav-logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(224, 145, 69, 0.1);
    border-radius: 6px;
    color: var(--accent-yellow);
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.nav-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.nav-logo-icon:has(img) {
    background: transparent;
    padding: 2px;
}

.nav-identity-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-org-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-org-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 2px;
}

.nav-org-chevron {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--nav-transition);
    flex-shrink: 0;
}

.nav-org-chevron:hover {
    color: var(--text-primary);
}

.nav-org-chevron i {
    font-size: 12px;
}

/* Dropdown de organización */
.nav-org-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-floating);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.nav-org-dropdown.open {
    display: block;
}

.nav-org-dropdown-header {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--nav-separator);
}

.nav-org-dropdown-list {
    padding: 8px 0;
}

.nav-org-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.nav-org-option:hover {
    background: var(--sidebar-hover);
}

.nav-org-option.active {
    background: var(--sidebar-active);
}

.nav-org-option-content {
    flex: 1;
    min-width: 0;
}

.nav-org-option-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.nav-org-option-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav-org-check {
    color: var(--accent-yellow);
    font-size: 14px;
    flex-shrink: 0;
}

.nav-org-divider {
    height: 1px;
    background: var(--nav-separator);
    margin: 8px 0;
}

.nav-org-option.create-org {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.nav-org-option.create-org i {
    width: 16px;
    font-size: 16px;
    text-align: center;
}

/* Ocultar identidad cuando está colapsado */
.side-navigation.collapsed .nav-identity-section {
    padding: 12px;
}

.side-navigation.collapsed .nav-workspace-header,
.side-navigation.collapsed .nav-identity-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
}

.side-navigation.collapsed .nav-identity-card {
    padding: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-navigation.collapsed .nav-identity-content {
    justify-content: center;
}

.side-navigation.collapsed .nav-identity-info,
.side-navigation.collapsed .nav-org-chevron {
    display: none;
}

.nav-collapsed-only-icon {
    display: none;
}

.side-navigation.collapsed .nav-collapsed-only-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-primary);
}

.side-navigation.collapsed .nav-workspace-header .nav-logo-icon,
.side-navigation.collapsed .nav-identity-section .nav-logo-icon,
.side-navigation.collapsed .nav-identity-section .nav-dev-icon {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

/* Footer collapsed: icon stack + divider, iconos centrados */
.side-navigation.collapsed .nav-footer {
    border-top: 1px solid var(--nav-border);
    padding: 12px 6px 16px;
    gap: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.side-navigation.collapsed .nav-footer-link,
.side-navigation.collapsed .nav-footer-action {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
}

.side-navigation.collapsed .nav-footer .nav-icon {
    margin: 0;
}

/* Footer desarrollador colapsado: mismo rail que el menú (iconos 40×40, sin texto) */
.side-navigation.collapsed.nav-mode-developer .nav-footer {
    padding: 12px 6px 16px;
    gap: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.side-navigation.collapsed.nav-mode-developer .nav-dev-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0;
    background: transparent;
    width: 100%;
    max-width: 40px;
}

.side-navigation.collapsed.nav-mode-developer .nav-dev-stat {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
}

.side-navigation.collapsed.nav-mode-developer .nav-dev-stat span {
    display: none;
}

/* Toggle button removido del sidebar - ahora está en el header */

/* Tooltips para estado colapsado: right center, max-width 180px, delay 150ms (JS) */
.nav-tooltip {
    position: fixed;
    left: 67px; /* 51px sidebar + 16px gap */
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 10002;
    box-shadow: var(--shadow-floating);
}

.nav-tooltip.show {
    opacity: 1;
    visibility: visible;
}

/* Flyout: mini mapa del módulo — Header (icono + nombre) | Body (tree) | Footer (CTA) */
.nav-flyout {
    position: fixed;
    left: 63px; /* 51px sidebar + 12px safe zone */
    width: 240px;
    max-height: calc(100vh - 32px);
    background: var(--bg-card);
    border: 1px solid var(--nav-border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    z-index: 10001;
    padding: 12px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease;
}

.nav-flyout.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Safe zone: puente invisible entre icono y flyout para no cerrar al mover el cursor */
.nav-flyout-bridge {
    position: absolute;
    left: -12px;
    top: 0;
    bottom: 0;
    width: 12px;
}

.nav-flyout-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 12px;
    background: var(--bg-card);
}

/* Header: icono 16px + nombre módulo 14px medium, divider */
.nav-flyout-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--nav-border);
}

.nav-flyout-header-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.nav-flyout-header-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Body: lista vertical con tree indicator (línea izquierda) */
.nav-flyout-body {
    padding: 4px 0;
    position: relative;
}

.nav-flyout-body::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--text-muted);
    opacity: 0.2;
    border-radius: 1px;
}

.nav-flyout-list {
    padding: 0;
    position: relative;
    z-index: 1;
}

.nav-flyout-link {
    display: block;
    padding: 6px 12px 6px 20px; /* indent: 10px line + 2px + 8px */
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.1s ease, color 0.1s ease;
}

.nav-flyout-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-flyout-link.active {
    background: var(--sidebar-active);
    color: var(--text-primary);
    font-weight: 500;
}

/* Footer: CTA secundario "Abrir [módulo] →" */
.nav-flyout-footer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--nav-border);
}

.nav-flyout-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}

.nav-flyout-cta:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-flyout-cta i {
    font-size: 12px;
    margin-left: 4px;
}

/* =========================================
   MENÚ PRINCIPAL
   ========================================= */

/* =========================================
   CAPA 2 — ESTRUCTURA (Dominios conceptuales)
   No lista páginas, lista dominios conceptuales
   ========================================= */

.nav-menu {
    padding: 0 12px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.nav-section {
    margin-bottom: 0;
}

.nav-section {
    margin-bottom: 0;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px 8px 12px;
    margin-bottom: 4px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.2;
}

.side-navigation.collapsed .nav-section-title {
    display: none;
}

/* =========================================
   DOMINIOS CONCEPTUALES — SEPARACIÓN VISUAL
   ========================================= */

.nav-item {
    position: relative;
    margin-bottom: 0;
}

/* Dominio 1: Actividad (vista operacional del workspace) */
.nav-item:first-child {
    margin-top: 0;
    margin-bottom: 5px; /* Espacio reducido después de Actividad */
}

/* Dominio 2: Marca (fundacional, sólida) */
.nav-item:nth-child(2) {
    margin-bottom: 5px; /* Espacio reducido después de Marca */
}

/* Dominio 3: Entidades (contenedor sólido) */
.nav-item-has-submenu[data-submenu="entidades"] {
    margin-top: 0;
    margin-bottom: 5px; /* Espacio reducido después de Entidades */
}

/* Dominio 4: Producción (operativo, activo) - ahora debajo de Entidades */
.nav-item-has-submenu[data-submenu="produccion"] {
    margin-top: 0;
    margin-bottom: 5px; /* Espacio reducido después de Producción */
}

/* Dominio 5: Audiencias + Marketing (juntos, mismo peso) */
.nav-item:nth-child(5),
.nav-item:nth-child(6) {
    margin-bottom: 5px; /* Espacio reducido entre items */
}

.nav-item:nth-child(6) {
    margin-bottom: 5px; /* Espacio reducido después del bloque Audiencias/Marketing */
}

/* =========================================
   ITEMS PRIMARIOS — PESO TIPOGRÁFICO NIVEL 1
   ========================================= */

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    height: var(--nav-item-height);
    min-height: var(--nav-item-height);
    color: var(--text-primary); /* Texto normal, no grita */
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
    font-weight: 400; /* Texto normal, no medium */
    font-size: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    margin-bottom: 0;
    border-radius: 6px;
    background: transparent;
}

/* Hover sutil */
.nav-link:hover {
    color: rgba(255, 255, 255, 0.95);
    background: var(--bg-hover);
}

/* Estado activo que susurra, no grita */
.nav-link.active {
    color: var(--text-primary); /* Texto 100%, pero no más grande */
    background: var(--bg-hover); /* Fondo apenas distinto */
    font-weight: 500; /* Ligeramente más peso, pero sutil */
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--icon-button);
    border-radius: 0 2px 2px 0;
}

.nav-link.active .nav-icon {
    color: rgba(255, 255, 255, 0.95); /* Ligeramente más brillante, pero sutil */
}


.nav-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: 900;
    font-style: normal;
    font-family: "Font Awesome 6 Free";
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    line-height: 1;
    -webkit-font-smoothing: antialiased;
}

.nav-link:hover .nav-icon {
    color: var(--accent-yellow);
}

.nav-link.active .nav-icon {
    color: #ffffff;
}

.nav-text {
    flex: 1;
    font-size: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: opacity 0.15s ease;
    opacity: 1;
    overflow: visible;
    line-height: 1.4;
    padding-top: 0;
}

.nav-badge {
    background: var(--accent-yellow);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.nav-badge.secondary {
    background: var(--text-muted);
}

.nav-badge.success {
    background: var(--success-color);
}

/* =========================================
   SUBMENÚS
   ========================================= */

/* =========================================
   DOMINIO 3: ENTIDADES — CONTENEDOR SÓLIDO Y FUNDACIONAL
   Se siente como arquitectura, no navegación plana
   ========================================= */

.nav-item-has-submenu {
    position: relative;
}

.nav-link-parent {
    cursor: pointer;
    font-weight: 500; /* Peso mayor que hijos, pero controlado */
    color: var(--text-primary); /* Ligeramente más visible que items normales */
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Chevron indicador de estado abierto/cerrado */
.nav-chevron {
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s ease, color 0.15s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-item-has-submenu.active .nav-chevron {
    transform: rotate(90deg);
    color: var(--text-secondary);
}

/* Entidades se siente fundacional */
.nav-item-has-submenu[data-submenu="entidades"] .nav-link-parent {
    font-weight: 500;
    color: var(--text-primary);
}

/* Producción se siente operativo */
.nav-item-has-submenu[data-submenu="produccion"] .nav-link-parent {
    font-weight: 500;
    color: var(--text-primary);
}

/* Item padre activo cuando un subitem está activo */
.nav-item-has-submenu.active > .nav-link-parent {
    color: var(--text-primary);
    background: var(--bg-hover);
    font-weight: 500;
}

.nav-item-has-submenu.active > .nav-link-parent::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--icon-button);
    border-radius: 0 2px 2px 0;
}

.nav-item-has-submenu.active > .nav-link-parent .nav-icon {
    color: rgba(255, 255, 255, 0.95);
}

/* =========================================
   NIVEL 3 — HIJOS SUBORDINADOS
   Se sienten subordinados, más pequeños, más silenciosos
   ========================================= */

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 0;
    margin-top: 2px;
    margin-bottom: 0;
}

.nav-submenu.open {
    max-height: 500px;
    padding-left: 0;
    margin-top: 2px;
}

.nav-submenu-item {
    position: relative;
    margin-left: 24px; /* Indentado real para subordinación clara */
    margin-bottom: 1px;
}

.nav-link-sub {
    padding-left: 12px;
    height: 32px; /* Más pequeño que padre */
    min-height: 32px;
    font-size: 13px; /* Tamaño menor - nivel 3 */
    font-weight: 400; /* Peso menor que el padre */
    position: relative;
    color: var(--text-muted); /* Color 60% - más silencioso */
}

/* Punto conector en la línea vertical (opcional, para mejor visualización) */
.nav-link-sub::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--icon-button);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2;
}

.nav-link-sub:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.nav-link-sub.active {
    color: var(--text-primary); /* No 100%, más sutil */
    background: var(--bg-hover);
    font-weight: 400; /* Sin cambio de peso */
}

.nav-link-sub.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--icon-button); /* Más sutil que el padre */
    border-radius: 0 2px 2px 0;
}

/* Sin flechas visibles siempre - solo cuando está abierto */
.nav-link-parent::after {
    display: none;
}

/* Ocultar submenús cuando el sidebar está colapsado */
.side-navigation.collapsed .nav-submenu {
    display: none;
}

.side-navigation.collapsed .nav-item-has-submenu.active .nav-link-parent {
    background: var(--bg-interactive);
}

/* El aire comunica estructura - espacios reales entre dominios */

/* =========================================
   FOOTER DEL PANEL: PERFIL
   ========================================= */

.nav-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    border-top: 1px solid var(--nav-separator);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.nav-footer-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--nav-transition);
    position: relative;
}

.nav-footer-profile:hover {
    background: var(--bg-hover);
}

.nav-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.nav-profile-avatar span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
}

.nav-profile-info {
    flex: 1;
    min-width: 0;
}

.nav-profile-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-profile-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-profile-chevron {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--nav-transition);
    flex-shrink: 0;
}

.nav-profile-chevron:hover {
    color: var(--text-primary);
}

.nav-profile-chevron i {
    font-size: 12px;
}

/* Dropdown de perfil */
.nav-profile-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-floating);
    z-index: 1000;
    display: none;
    overflow: hidden;
    margin-bottom: 8px;
}

.nav-profile-dropdown.open {
    display: block;
}

.nav-profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--nav-transition);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
}

.nav-profile-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-profile-dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.nav-profile-dropdown-item.nav-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.nav-profile-dropdown-item.nav-logout:hover i {
    color: #ef4444;
}

/* Estado colapsado del footer */
.side-navigation.collapsed .nav-footer-profile {
    justify-content: center;
    padding: 8px;
}

.side-navigation.collapsed .nav-profile-avatar {
    width: 40px;
    height: 40px;
}

/* =========================================
   CONTENIDO PRINCIPAL
   ========================================= */

/* El offset del sidebar lo aplica solo body.has-sidebar #app-container; .main-content no añade margin. */
.main-content {
    margin-top: 0;
    margin-left: 0;
    min-height: 100vh;
    height: auto;
    background: var(--bg-primary);
    padding-top: 48px; /* Altura del header delgado */
    position: relative;
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.content-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* =========================================
   BREADCRUMBS
   ========================================= */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2rem;
    padding: 0 2rem;
    font-size: 0.9rem;
}

.breadcrumb-item {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--nav-transition);
}

.breadcrumb-item:hover {
    color: var(--accent-yellow);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

@media (max-width: 768px) {
    .main-header {
        padding: 12px 16px;
        left: 0 !important;
        max-width: 100vw;
    }
    
    #app-container .main-header {
        left: 0 !important;
        max-width: 100vw;
    }
    
    .header-content {
        max-width: 100%;
    }
    
    .side-navigation {
        width: var(--nav-width);
        transform: translateX(-100%);
        transition: var(--nav-transition);
    }
    
    .side-navigation.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding-top: 48px; /* Altura del header en móvil */
    }
    
    .nav-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--nav-overlay);
        /* backdrop-filter removido para mejor rendimiento - overlay pequeño pero no crítico */
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: var(--nav-transition);
    }
    
    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .content-container {
        padding: 1rem;
    }
    
    .breadcrumbs {
        padding: 0 1rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .nav-header {
        padding: 1.5rem 1rem 1rem;
    }
    
    .nav-footer {
        padding: 1rem;
    }
    
    .nav-user-details h4 {
        font-size: 0.9rem;
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: 10px 1.25rem;
    }
    
    .nav-icon {
        font-size: 0.9rem;
    }
    
    .nav-logout {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
    
    .content-container {
        padding: 0.5rem;
    }
}

/* =========================================
   ESTADOS ESPECIALES
   ========================================= */

.nav-item.coming-soon .nav-text::after {
    content: 'Próximamente';
    font-size: 0.7rem;
    color: var(--warning-color);
    background: rgba(245, 158, 11, 0.2);
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 8px;
}

.nav-item.beta .nav-text::after {
    content: 'Beta';
    font-size: 0.7rem;
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.2);
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 8px;
}

/* =========================================
   SISTEMA DE LAYOUT INTELIGENTE
   Controla el layout según la ruta actual
   ========================================= */

/* === LAYOUT: SIN NAVEGACIÓN (Páginas públicas) === */
body.no-nav #navigation-container {
    display: none;
}

body.no-nav #app-container {
    margin-left: 0;
    padding-top: 0;
}

/* === LAYOUT: SOLO HEADER (Home/Hogar) === */
body.has-header-only #app-container {
    margin-left: 0;
    padding-top: 70px;
}

/* === LAYOUT: CON SIDEBAR (Org y Dev) === */
body.has-sidebar #app-container {
    margin-left: var(--nav-width, 260px);
    max-width: calc(100vw - var(--nav-width, 260px));
    padding-top: var(--app-header-height, 45.8px);
    transition: margin-left 0.3s ease;
    box-sizing: border-box;
}

body.has-sidebar.sidebar-collapsed #app-container {
    margin-left: var(--nav-width-collapsed, 72px);
    max-width: calc(100vw - var(--nav-width-collapsed, 72px));
}

/* Sin padding superior en Products (#app-container > div) y Living (#app-container > main); lo aplican sus contenedores internos */
body.has-sidebar #app-container:has(> div.product-view),
body.has-sidebar #app-container:has(> div.main-content > div.products-container),
body.has-sidebar #app-container:has(> main.living-main-content) {
    padding-top: 0;
}

/* =========================================
   APP HEADER (Nuevo sistema)
   ========================================= */

.app-header {
    position: fixed;
    top: 0;
    right: 0;
    height: var(--app-header-height, 45.8px);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    z-index: 900;
    display: flex;
    align-items: center;
}

/* Header solo (sin sidebar) - Home/Hogar */
.app-header.header-only {
    left: 0;
}

/* Header con sidebar */
.app-header.with-sidebar {
    left: var(--nav-width, 260px);
    max-width: calc(100vw - var(--nav-width, 260px));
    transition: left 0.3s ease;
    box-sizing: border-box;
}

body.sidebar-collapsed .app-header.with-sidebar {
    left: var(--nav-width-collapsed, 72px);
    max-width: calc(100vw - var(--nav-width-collapsed, 72px));
}

/* #appHeader > .header-content: adaptar al ancho del header (no desbordar) */
#appHeader > .header-content,
.app-header .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0 20px;
    gap: 16px;
    box-sizing: border-box;
}

.app-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex-shrink: 1;
}

.app-header .header-logo {
    display: flex;
    align-items: center;
}

.app-header .header-logo .logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

/* Oculto por defecto (solo header sin sidebar, ej. Hogar) */
.app-header .header-hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

/* Visible cuando hay sidebar (desktop y móvil) para colapsar/abrir */
.app-header.with-sidebar .header-hamburger {
    display: flex;
}

.app-header .header-hamburger:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.app-header .header-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.app-header .header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.app-header .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-shrink: 0;
}

/* Usuario en header: solo botón menú (avatar quitado por diseño) */
.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.user-menu-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.user-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--nav-border);
}

.user-dropdown-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-dropdown-email {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--nav-border);
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.user-dropdown-item i {
    width: 18px;
    font-size: 14px;
}

/* Switcher Consumidor / Desarrollador (solo para usuarios con is_developer) */
.user-dropdown-mode-switcher {
    padding: 12px 16px;
}

.user-dropdown-mode-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.user-dropdown-mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.user-dropdown-mode-option:hover {
    color: var(--text-primary);
}

.user-dropdown-mode-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-warm);
    cursor: pointer;
}

.user-dropdown-mode-option input[type="radio"]:checked + span {
    color: var(--text-primary);
    font-weight: 500;
}

/* =========================================
   SIDEBAR - IDENTIDAD Y ORGANIZACIÓN
   ========================================= */

.nav-identity-section {
    padding: 16px;
    border-bottom: 1px solid var(--nav-border);
    position: relative;
}

.nav-identity-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-identity-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-color);
}

.nav-identity-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.nav-identity-info {
    flex: 1;
    min-width: 0;
}

.nav-org-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-org-type {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav-org-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-org-chevron:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Developer Identity Card - Idéntico al consumidor (Living/Brands): misma card, mismo icono naranja */
.nav-identity-card.dev-identity {
    background: var(--bg-hover);
    border: 1px solid var(--border-divider);
}

.nav-identity-card.dev-identity:hover {
    background: var(--bg-hover);
    border-color: var(--border-divider);
}

.nav-dev-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.nav-dev-icon .nav-dev-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Organization Dropdown */
.nav-org-dropdown {
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.nav-org-dropdown.active {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(8px);
}

.nav-org-dropdown-header {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--nav-border);
}

.nav-org-dropdown-list {
    padding: 8px 0;
}

.nav-org-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.nav-org-option:hover {
    background: var(--sidebar-hover);
}

.nav-org-option.active {
    background: var(--sidebar-active);
}

.nav-org-option-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-org-option-avatar span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.nav-org-option-info {
    flex: 1;
    min-width: 0;
}

.nav-org-option-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.nav-org-option-role {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
    margin-top: 1px;
}

.nav-org-option i.fa-check {
    color: var(--success-color);
    font-size: 16px;
    flex-shrink: 0;
}

.nav-org-divider {
    height: 1px;
    background: var(--nav-border);
    margin: 8px 0;
}

.nav-org-home,
.nav-org-create {
    color: var(--text-secondary);
}

.nav-org-home i,
.nav-org-create i {
    width: 16px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-icon-color);
}

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

.nav-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Tokens Display */
.nav-tokens {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 10px;
    font-size: 13px;
}

.nav-tokens i {
    color: #fbbf24;
    font-size: 16px;
}

.nav-tokens #navTokensValue {
    font-weight: 600;
    color: var(--text-primary);
}

.nav-tokens .nav-tokens-label {
    color: var(--text-muted);
    font-size: 12px;
}

/* Developer Stats */
.nav-dev-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 10px;
}

.nav-dev-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.nav-dev-stat i {
    font-size: 14px;
}

.nav-dev-stat i {
    font-size: 14px;
    color: var(--accent-yellow);
}

.nav-dev-stat span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

/* Mode Switch Button - Mismo estilo que nav-tokens (card sutil, acento naranja al hover) */
.nav-mode-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--nav-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-mode-switch:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--accent-yellow);
}

.nav-mode-switch i {
    font-size: 14px;
    color: var(--text-muted);
}

.nav-mode-switch:hover i {
    color: var(--accent-yellow);
}

/* =========================================
   SIDEBAR MÓVIL
   ========================================= */

@media (max-width: 768px) {
    /* Header hamburger visible */
    .app-header .header-hamburger {
        display: flex;
    }

    /* Header ocupa todo el ancho */
    .app-header.with-sidebar {
        left: 0;
        max-width: 100vw;
    }

    /* Sidebar oculto por defecto en móvil */
    .side-navigation {
        transform: translateX(-100%);
    }

    .side-navigation.mobile-open {
        transform: translateX(0);
    }

    /* App container sin margen en móvil; ancho completo sin desborde */
    body.has-sidebar #app-container {
        margin-left: 0;
        max-width: 100vw;
        padding-top: var(--app-header-height, 45.8px);
    }

    /* Misma excepción en móvil: sin padding superior en Products y Living */
    body.has-sidebar #app-container:has(> div.product-view),
    body.has-sidebar #app-container:has(> div.main-content > div.products-container),
    body.has-sidebar #app-container:has(> main.living-main-content) {
        padding-top: 0;
    }

    /* Overlay visible cuando nav está abierta */
    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* =========================================
   OVERLAY DE NAVEGACIÓN
   ========================================= */

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 800;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =========================================
   SIDEBAR NAVEGACIÓN PRINCIPAL
   ========================================= */

.side-navigation {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-width, 260px);
    height: 100vh;
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    z-index: 850;
    transition: all 0.3s ease;
}

/* =========================================
   MENÚ DE NAVEGACIÓN
   ========================================= */

/* Spacer entre navegación principal y footer (Zona 1 vs Zona 2) */
.nav-spacer {
    flex: 1;
    min-height: 0;
}

.nav-menu {
    flex: 0 0 auto;
    overflow-y: auto;
    padding: 16px;
}

.nav-item {
    margin-bottom: 0;
}

/* Reglas visuales sidebar usuario: 36px altura, 13px, 16px padding, 10px icon spacing, 8px radius */
.nav-mode-user .nav-link,
.nav-mode-user .nav-main-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    color: var(--sidebar-text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-mode-user .nav-link:hover,
.nav-mode-user .nav-main-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-primary);
}

.nav-mode-user .nav-link.active,
.nav-mode-user .nav-main-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-primary);
}

.nav-mode-user .nav-icon {
    width: 16px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-icon-color);
}

.nav-mode-user .nav-text {
    flex: 1;
}

.nav-mode-user .nav-chevron {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

/* Submenú: indent 18px, solo texto, peso 400 */
.nav-item.has-submenu .nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-item.has-submenu.submenu-open .nav-submenu {
    max-height: 320px;
    overflow-y: auto;
}

.nav-item.has-submenu.submenu-open .nav-chevron {
    transform: rotate(90deg);
}

.nav-mode-user .nav-submenu-link {
    display: flex;
    align-items: center;
    padding: 0 16px 0 34px; /* 16 + 18px indent */
    min-height: 36px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    border-radius: 8px;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-mode-user .nav-submenu-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-secondary);
}

.nav-mode-user .nav-submenu-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-primary);
}

/* Compatibilidad: sidebar dev y otros mantienen estilos anteriores */
.side-navigation:not(.nav-mode-user) .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--nav-item-height);
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--sidebar-text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.side-navigation:not(.nav-mode-user) .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-primary);
}

.side-navigation:not(.nav-mode-user) .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-primary);
    font-weight: 500;
}

.side-navigation:not(.nav-mode-user) .nav-icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-icon-color);
}

.side-navigation:not(.nav-mode-user) .nav-submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 48px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.side-navigation:not(.nav-mode-user) .nav-submenu-link:hover,
.side-navigation:not(.nav-mode-user) .nav-submenu-link.active {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Lead: gobernanza, diferenciación visual (spacing superior, acento sutil) */
.nav-mode-developer .nav-dev-lead-section {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--nav-border);
}

.nav-mode-developer .nav-dev-lead-section .nav-link.nav-submenu-toggle .nav-icon {
    color: var(--text-primary);
}

/* Zona 2: Footer organizacional (Configuración, Planes, Créditos, Salir) */
.nav-mode-user .nav-footer {
    flex-shrink: 0;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-mode-user .nav-footer-link,
.nav-mode-user .nav-footer-action {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    color: var(--sidebar-text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-mode-user .nav-footer-link:hover,
.nav-mode-user .nav-footer-action:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-primary);
}

.nav-mode-user .nav-footer-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-primary);
}

/* =========================================
   PÁGINA DE ERROR
   ========================================= */

.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.error-content h1 {
    font-size: 6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.error-content p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.error-actions .btn-primary {
    background: var(--text-primary);
    color: var(--nav-bg);
}

.error-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 235, 218, 0.2);
}

.error-actions .btn-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.error-actions .btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
