/* ==========================================================================
   NEXTZHOP HUB CORE (V40.0 - PURE NATIVE & OBSIDIAN COUTURE)
   Chasis de componentes estructurales. Minimalismo Táctico y Blindaje Móvil.
   ========================================================================== */

/* ==========================================================================
   1. RESET UNIVERSAL Y ANTI-SCROLL HORIZONTAL
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { width: 100%; overflow-x: hidden; }

body {
    width: 100%; position: relative; overflow-x: clip; 
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 🚀 FIX SENIOR: Blindaje de scroll elástico para el Hub */
body.nz-is-platform {
    background-color: var(--hub-bg-app) !important;
    color: var(--hub-text-main) !important;
    font-family: var(--hub-font, sans-serif);
    margin: 0; 
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. TIPOGRAFÍA Y MARCA
   ========================================================================== */
.nz-hub-brand { 
    font-family: var(--hub-font-display, 'Didot', serif); 
    font-weight: 400; text-transform: uppercase; letter-spacing: -0.02em; line-height: 0.85; 
}
.nz-hub-label { 
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace); 
    font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3em; 
    color: var(--hub-text-muted); 
}
.nz-hub-title { 
    font-family: var(--hub-font-display, 'Didot', serif); 
    font-size: 42px; font-weight: 400; font-style: italic; text-transform: uppercase; 
    margin: 0; line-height: 0.9; color: var(--hub-text-main); 
}

/* ==========================================================================
   3. LAYOUT (El Chasis del Panel)
   ========================================================================== */
.nz-hub-sidebar {
    display: none; width: 256px; border-right: 1px solid var(--hub-border); 
    padding: calc(40px + env(safe-area-inset-top)) 40px 40px 40px; 
    position: fixed; height: 100vh; height: 100dvh;
    background-color: var(--hub-bg-sidebar); z-index: 1000;
}
.nz-hub-main { 
    min-height: 100vh; min-height: 100dvh;
    background-color: var(--hub-bg-app); flex: 1; 
    padding-top: env(safe-area-inset-top); padding-bottom: 0px; 
    max-width: 100%; overflow-x: clip; 
}

/* ==========================================================================
   4. COMPONENTES: TARJETAS
   ========================================================================== */
.nz-hub-card {
    background-color: var(--hub-bg-card); border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius-card);  padding: 2rem;
    transition: all var(--hub-transition); max-width: 100%; 
}
.nz-hub-card.is-active { 
    background-color: var(--hub-bg-app); border-color: var(--hub-accent); box-shadow: 0 10px 30px var(--hub-accent-soft); 
}
@media (hover: hover) {
    .nz-hub-card:hover { border-color: var(--hub-text-main); transform: translateY(-2px); }
}

/* ==========================================================================
   5. COMPONENTES: BOTONES Y LINKS
   ========================================================================== */
.nz-hub-btn {
    background-color: var(--hub-text-main); color: var(--hub-text-inverse);
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace);
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.25em;
    border: 1px solid var(--hub-text-main); border-radius: var(--hub-radius-btn);
    padding: 16px 32px; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--hub-transition); min-height: 44px; text-align: center;
}
@media (hover: hover) {
    .nz-hub-btn:hover { background-color: transparent; color: var(--hub-text-main); transform: translateY(-2px); }
}

.nz-hub-nav-link {
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace);
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2em;
    color: var(--hub-text-muted); text-decoration: none; transition: color 0.4s ease;
}
.nz-hub-nav-link.active { border-left: 2px solid var(--hub-accent); padding-left: 10px; color: var(--hub-text-main); }
.nz-hub-nav-link.is-accent { color: var(--hub-accent); }
@media (hover: hover) { .nz-hub-nav-link:hover { color: var(--hub-text-main); } }

/* ==========================================================================
   6. COMPONENTES: MODALES Y OVERLAYS
   ========================================================================== */
#social-modal { display: none; z-index: 99999; }
.nz-hub-modal-content { 
    background-color: var(--hub-bg-glass); backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--hub-border); border-radius: var(--hub-radius-card); 
    max-height: 80vh; width: 100%; max-width: 450px; overflow-y: auto; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.08); 
}
.nz-hub-modal-title { color: var(--hub-text-main); font-family: var(--hub-font-display, serif); font-style: italic; }

/* ==========================================================================
   7. COMPONENTES: STOREFRONT BUILDER UI & INPUTS
   ========================================================================== */
.nz-hub-input {
    background: transparent; border: none; border-bottom: 1px solid var(--hub-border); color: var(--hub-text-main);
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em;
    padding: 12px 0; outline: none; width: 100%; transition: all 0.4s ease; border-radius: 0; 
}
.nz-hub-input:focus { border-color: var(--hub-text-main); box-shadow: 0 1px 0 0 var(--hub-text-main); }

/* ==========================================================================
   8. COMPONENTES: LOGÍSTICA & PESTAÑAS
   ========================================================================== */
.nz-hub-filter-tab {
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace);
    font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2em;
    padding: 12px 16px; border-bottom: 2px solid transparent; color: var(--hub-text-muted);
    transition: all 0.4s ease; white-space: nowrap; cursor: pointer; min-height: 44px; 
}
.nz-hub-filter-tab.active { color: var(--hub-text-main); border-color: var(--hub-text-main); }
@media (hover: hover) { .nz-hub-filter-tab:hover { color: var(--hub-text-main); } }

/* Cajón Lateral Deslizable */
.nz-hub-drawer-overlay { opacity: 0; pointer-events: none; transition: opacity 0.5s ease; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); }
.nz-hub-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.nz-hub-drawer { background-color: var(--hub-bg-app); border-left: 1px solid var(--hub-border); transform: translateX(100%); transition: transform var(--hub-transition); max-width: 100vw; }
.nz-hub-drawer.open { transform: translateX(0); }

select.nz-hub-select {
    appearance: none; background-color: transparent; border: 1px solid var(--hub-border); color: var(--hub-text-main); 
    padding: 14px 16px; border-radius: var(--hub-radius-btn); width: 100%;
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; outline: none; cursor: pointer;
}
select.nz-hub-select:focus { border-color: var(--hub-text-main); }

@media (max-width: 767px) { .nz-hub-input, select.nz-hub-select { font-size: 16px !important; letter-spacing: 0.05em !important; } }

/* ==========================================================================
   9. COMPONENTES: SETTINGS & TABS
   ========================================================================== */
.nz-hub-config-card { background: var(--hub-bg-card); border: 1px solid var(--hub-border); border-radius: var(--hub-radius-card); }
.nz-hub-radio-card {
    padding: 1.5rem; border: 1px solid var(--hub-border); background-color: var(--hub-bg-app); color: var(--hub-text-muted);
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace); font-size: 9px; font-weight: 700; text-transform: uppercase; text-align: center; letter-spacing: 0.25em; 
    transition: all 0.4s ease; border-radius: var(--hub-radius-card);
}
input:checked + .nz-hub-radio-card { border-color: var(--hub-text-main); color: var(--hub-text-main); box-shadow: inset 0 0 0 1px var(--hub-text-main); }
.nz-hub-tab-content { display: none; }
.nz-hub-tab-content.active { display: block; animation: nzFadeIn var(--hub-transition); }
@keyframes nzFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   10. COMPONENTES: SYSTEM FEEDBACK & TERMINAL UI
   ========================================================================== */
.nz-hub-terminal-grid { position: fixed; inset: 0; z-index: -1; background-image: radial-gradient(var(--hub-border) 1px, transparent 1px); background-size: 32px 32px; background-position: center; }

/* ==========================================================================
   11. COMPONENTES: NODE ENGINE NAV (LAB NAV)
   ========================================================================== */
.nz-lab-nav {
    display: flex; gap: 2.5rem; border-bottom: 1px solid var(--hub-border);
    background-color: var(--hub-bg-app); overflow-x: auto; white-space: nowrap; padding: 0 2rem;
    -ms-overflow-style: none; scrollbar-width: none; max-width: 100%; 
}
.nz-lab-nav::-webkit-scrollbar { display: none; }

.nz-lab-nav .lab-link {
    font-family: var(--hub-font-mono, 'JetBrains Mono', monospace); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.25em;
    color: var(--hub-text-muted); text-decoration: none; padding: 0; border-bottom: 2px solid transparent; transition: all var(--hub-transition);
    display: inline-flex; align-items: center; min-height: 48px; position: relative; bottom: -1px;
}
.nz-lab-nav .lab-link.active { color: var(--hub-text-main); border-bottom-color: var(--hub-text-main); }

/* ==========================================================================
   12. COMPONENTES: APP SHELL MASTER HEADER (RESTURADO DESDE master-head.php)
   ========================================================================== */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.nz-safe-top { padding-top: env(safe-area-inset-top) !important; }

@keyframes nz-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
.nz-animate-pulse { animation: nz-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

.nz-master-header {
    display: flex; flex-direction: column; width: 100%;
    background-color: var(--hub-bg-main); border-bottom: 1px solid var(--hub-border);
    user-select: none; flex-shrink: 0; 
    /* 🚀 FIX SENIOR: Anclaje estático absoluto en el techo de la UI */
    position: sticky; top: 0; z-index: 9000;
}

.nz-header-top-row {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; height: 60px; padding: 0 24px;
}

.nz-header-left { display: flex; align-items: center; width: 25%; }
.nz-header-center { display: flex; align-items: center; justify-content: center; width: 50%; }
.nz-header-right { display: flex; align-items: center; justify-content: flex-end; width: 25%; }

.nz-logo-link { display: flex; align-items: center; transition: opacity 0.3s; }
.nz-logo-link:hover { opacity: 0.6; }

.nz-master-logo { 
    height: var(--hub-logo-height, 26px); width: auto; object-fit: contain; 
    filter: invert(var(--hub-logo-invert, 0)); 
}

.nz-header-icon {
    color: var(--hub-text-main); display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; transition: opacity 0.3s ease; position: relative;
}
.nz-header-icon.is-active { opacity: 1; }
.nz-header-icon.is-inactive { opacity: 0.4; }
.nz-header-icon.is-inactive:hover { opacity: 1; }

.nz-notification-dot {
    position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; 
    border-radius: 50%; background-color: var(--hub-accent); box-shadow: 0 0 8px var(--hub-accent);
}

.nz-hybrid-nav { 
    display: flex; gap: 24px; overflow-x: auto; white-space: nowrap; 
    width: 100%; max-width: 100%;
}
.nz-hybrid-link {
    font-family: var(--hub-font-mono, monospace); font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--hub-text-muted); text-decoration: none; border-bottom: 2px solid transparent; transition: all 0.3s;
    display: inline-flex; align-items: center; height: 100%; padding: 0 4px; min-height: 48px;
}
.nz-hybrid-link:hover { color: var(--hub-text-main); }
.nz-hybrid-link.active { color: var(--hub-text-main); border-bottom-color: var(--hub-text-main); }

.nz-header-search-ghost {
    width: 100%; max-width: 400px; height: 32px; background: transparent; border: 1px solid var(--hub-border); display: flex; align-items: center; padding: 0 16px; border-radius: var(--hub-radius-btn);
}
.nz-header-search-ghost span {
    opacity: 0.3; font-size: 10px; font-family: var(--hub-font-mono, monospace); color: var(--hub-text-main); font-weight: bold; letter-spacing: 0.1em;
}

@media (min-width: 768px) {
    .nz-hybrid-nav { height: 60px; justify-content: center; }
    .nz-hybrid-link { min-height: 60px; }
    .nz-tenant-nav-wrapper-mobile { display: none; }
}
@media (max-width: 767px) {
    .nz-header-center { display: none; }
    .nz-header-left, .nz-header-right { width: 50%; }
    .nz-tenant-nav-wrapper-mobile { width: 100%; border-top: 1px solid var(--hub-border); padding: 0 24px; }
}

/* =========================================================================
   🚀 SMART TRANSITION ENGINE (SKELETON LOADER)
   ========================================================================= */
#nz-transition-overlay {
    position: fixed; inset: 0; z-index: 9999999;
    background-color: var(--hub-bg-main, #000);
    display: none; flex-direction: column; align-items: center; justify-content: center;
}
#nz-transition-img {
    height: 40px; width: auto; object-fit: contain;
    filter: invert(var(--hub-logo-invert, 0)); opacity: 0.8;
    animation: nzTransitionFloat 2s ease-in-out infinite;
}
#nz-transition-bar-wrapper {
    position: absolute; bottom: env(safe-area-inset-bottom); left: 0; right: 0;
    height: 2px; background-color: var(--hub-border, rgba(255,255,255,0.1)); overflow: hidden;
}
#nz-transition-bar-progress {
    height: 100%; width: 0%; background-color: var(--hub-text-main, #fff);
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes nzTransitionFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ==========================================================================
   13. COMPONENTES: MOBILE BOTTOM NAV BASE (Anclada & Nativa)
   ========================================================================== */
.nz-bottom-nav-base { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    z-index: 9900;
    /* ⚡ MICRO-AJUSTE 1: Cortamos el espacio excesivo de iOS/Android a la mitad */
    padding-bottom: calc(env(safe-area-inset-bottom) * 0.5);
    background-color: var(--hub-bg-main); 
    border-top: 1px solid var(--hub-border);
    /* Forzamos aceleración por hardware para evitar redibujados */
    transform: translateZ(0);
}

/* Ocultar en pantallas de escritorio o tablets grandes */
@media (min-width: 768px) { 
    .nz-bottom-nav-base { display: none; } 
}

.nz-bottom-nav-inner {
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    width: 100%; 
    padding: 0 16px; 
    overflow: hidden; 
    /* ⚡ MICRO-AJUSTE 2: Altura estándar (más delgada y estética) */
    height: 50px; 
}

/* Botones de Navegación */
.nz-nav-btn { 
    position: relative; 
    z-index: 10; 
    padding: 12px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    height: 100%; 
    flex: 1;
    transition: opacity var(--hub-transition, 0.3s ease); 
}
.nz-nav-btn.is-active { opacity: 1; color: var(--hub-accent); }
.nz-nav-btn.is-inactive { opacity: 0.4; color: var(--hub-text-main); }
.nz-nav-btn.is-inactive:hover { opacity: 1; }

/* Indicador de pestaña activa bajado para no chocar con los íconos */
.nz-nav-indicator {
    position: absolute; 
    bottom: 4px; 
    width: 4px; 
    height: 4px; 
    background-color: currentColor; 
    box-shadow: 0 0 5px currentColor;
}

/* Contenedor del botón central (Cámara) */
.nz-nav-action-slot {
    position: relative; 
    z-index: 10; 
    padding: 0 8px; 
    flex: 1; 
    display: flex; 
    justify-content: center;
}

/* Botón de Acción Principal */
.nz-camera-trigger {
    background-color: var(--hub-text-main); 
    color: var(--hub-bg-main);
    border: none; 
    border-radius: 50%;
    width: 40px; 
    height: 40px;
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer; 
    transition: transform 0.2s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.nz-camera-trigger:active { transform: scale(0.9); }

/* --- Animaciones y Texturas de Fondo --- */
@keyframes nzMatrixBreathe {
    0%, 90%, 100% { opacity: 0; filter: drop-shadow(0 0 0 transparent); }
    95% { opacity: 0.6; filter: drop-shadow(0 0 4px var(--hub-accent)); }
}

.nz-texture-base {
    position: absolute; 
    inset: 0; 
    z-index: 0; 
    opacity: 0.1; 
    pointer-events: none; 
    background-image: radial-gradient(var(--hub-text-main) 1px, transparent 1px); 
    background-size: 8px 8px;
}
.nz-texture-glow {
    position: absolute; 
    inset: 0; 
    z-index: 0; 
    pointer-events: none; 
    background-image: radial-gradient(var(--hub-accent) 1px, transparent 1px); 
    background-size: 8px 8px;
    animation: nzMatrixBreathe 5s infinite ease-in-out;
}

/* ==========================================================================
   14. NEXTZHOP UTILITY SHIELD
   ========================================================================== */
.hidden { display: none !important; }
.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.inset-0 { top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; }
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }
.h-screen { height: 100vh !important; }
.overflow-hidden { overflow: hidden !important; }
.shrink-0 { flex-shrink: 0 !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* REGLAS DE RESPONSIVIDAD NATIVAS FIX */
@media (max-width: 767px) {
    .md\:flex { display: none !important; }
    .md\:hidden { display: flex !important; }
}
@media (min-width: 768px) {
    .md\:flex { display: flex !important; }
    .md\:hidden { display: none !important; }
}