/**
 * CYBERNORTH - Academia de Ingeniería y Tecnología
 * Hoja de Estilos Centralizada (Mobile-First Architecture & cPanel Ready)
 * Compatible con cPanel / Apache / LiteSpeed / Nginx
 * Optimizado para Móviles (320px+), Tablets (768px+) y Escritorios (1024px - 2560px)
 */

/* ==========================================================================
   1. VARIABLES DE DISEÑO (DESIGN TOKENS & SAFE AREAS)
   ========================================================================== */
:root {
    --brand-dark: #070b14;
    --brand-navy: #0b1329;
    --brand-card: #111b33;
    --brand-card-hover: #162444;
    --brand-border: #1e293b;
    --brand-border-light: rgba(255, 255, 255, 0.12);
    --brand-cobalt: #1d4ed8;
    --brand-blue: #2563eb;
    --brand-blue-hover: #3b82f6;
    --brand-crimson: #dc2626;
    --brand-fire: #ef4444;
    --brand-neon: #06b6d4;
    --brand-emerald: #10b981;
    --brand-amber: #f59e0b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-tech: 'Rajdhani', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Touch Target WCAG / Apple HIG */
    --tap-min-size: 44px;
    --tap-comfortable: 48px;

    /* Safe Area insets para dispositivos con notch (iPhone X - 16+) */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   2. RESET Y BASE MOBILE-FIRST (CERO DESBORDAMIENTO HORIZONTAL)
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    /* ======================================================================
       ESCALADO GLOBAL MEJORADO PARA MÁXIMA LEGIBILIDAD (TODAS LAS PESTAÑAS)
       Base aumentada a 18px (1rem = 18px, +12.5% sobre estándar de 16px)
       ====================================================================== */
    font-size: 18px;
}

/* Teléfonos Móviles (320px - 639px): Mayor tamaño para lectura cómoda y descanso visual */
@media (max-width: 639px) {
    html {
        font-size: 18px;
    }
}

/* Tablets (640px - 1023px): Elementos y textos más amplios en pantallas medianas */
@media (min-width: 640px) and (max-width: 1023px) {
    html {
        font-size: 19px;
    }
}

/* Laptops y Escritorio (1024px - 1535px) */
@media (min-width: 1024px) and (max-width: 1535px) {
    html {
        font-size: 18px;
    }
}

/* Monitores de Gran Formato (1536px+) */
@media (min-width: 1536px) {
    html {
        font-size: 19.5px;
    }
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    background-color: #ffffff;
    color: #1e293b;
    font-family: var(--font-sans);
    line-height: 1.6;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Evita el rebote de scroll blanco en navegadores WebKit */
    overscroll-behavior-y: none;
}

img, video, canvas, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Reglas explícitas para el motor de animación scroll-scrubbing de portada */
.hero-scroll-track {
    position: relative;
    height: 360vh;
    min-height: 2200px;
    width: 100%;
}

.hero-sticky-container {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    z-index: 1;
}

.hero-scroll-canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Altura dinámica de viewport móvil (soluciona barras de navegación retráctiles) */
.mobile-dvh-screen {
    height: 100vh;
    height: 100dvh;
}

/* ==========================================================================
   3. NAVEGACIÓN SUPERIOR INTELIGENTE & BARRA INFERIOR MÓVIL (BOTTOM DOCK)
   ========================================================================== */
#mainHeaderNav {
    padding-top: var(--sat);
    background-color: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 2px 14px -3px rgba(0, 0, 0, 0.06);
    opacity: 1 !important;
    transform: translateY(0px) !important;
    pointer-events: auto !important;
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Color Azul Institucional Exacto al Logo (#1C48C9 / RGB: 28, 72, 201) */
.brand-blue-bg {
    background-color: #1C48C9 !important;
}
.brand-blue-border {
    border-color: #1C48C9 !important;
}
.brand-blue-text {
    color: #1C48C9 !important;
}

/* Pestaña Activa en el Menú Superior: Cuadro Azul Idéntico al Logo (#1C48C9) */
.nav-tab-active {
    background-color: #1C48C9 !important;
    border: 1px solid #1C48C9 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(28, 72, 201, 0.4) !important;
}

/* Pestañas Inactivas sobre Fondo Blanco */
.nav-tab-inactive {
    background-color: transparent !important;
    border: 1px solid transparent !important;
    color: #1e293b !important;
    font-weight: 600 !important;
}

.nav-tab-inactive:hover {
    color: #1C48C9 !important;
    background-color: rgba(28, 72, 201, 0.06) !important;
}

/* Estado scrolled del header mantiene nitidez y fondo blanco */
#mainHeaderNav.nav-scrolled-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid rgba(203, 213, 225, 0.95);
    box-shadow: 0 4px 18px -4px rgba(0, 0, 0, 0.08);
}

#mainHeaderNav #mobileMenuBtn {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

/* Modo translúcido integrado para el Laboratorio Virtual */
#mainHeaderNav.nav-lab-header {
    background-color: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

/* Laboratorio Virtual: Espaciado superior estricto para evitar solapamiento de la barra de navegación fija */
#tab-lab {
    padding-top: 72px !important; /* móvil */
    background-color: #0f172a;
}

@media (min-width: 640px) {
    #tab-lab {
        padding-top: 100px !important; /* tablet / desktop */
    }
}

#labLoginIframe {
    width: 100%;
    height: calc(100vh - 72px) !important;
    height: calc(100dvh - 72px) !important;
    min-height: 680px;
    border: none;
    display: block;
}

@media (min-width: 640px) {
    #labLoginIframe {
        height: calc(100vh - 100px) !important;
        height: calc(100dvh - 100px) !important;
        min-height: 850px;
    }
}

/* ==========================================================================
   VISIBILIDAD Y REALCE DE ÍCONOS EN LA CABECERA (100% NÍTIDOS EN CADA ESTADO)
   ========================================================================== */
.nav-tab-active i,
.nav-tab-active .nav-icon {
    color: #ffffff !important;
    display: inline-block !important;
    font-size: 1.15rem !important;
    line-height: 1 !important;
    opacity: 1 !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)) !important;
}

.nav-tab-inactive i,
.nav-tab-inactive .nav-icon {
    color: #1C48C9 !important;
    display: inline-block !important;
    font-size: 1.15rem !important;
    line-height: 1 !important;
    opacity: 1 !important;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-tab-inactive:hover i,
.nav-tab-inactive:hover .nav-icon {
    color: #1C48C9 !important;
    transform: scale(1.12);
}

/* Ícono del Laboratorio Virtual en pestaña inactiva */
.nav-tab-inactive i.fa-microchip,
.nav-tab-inactive .nav-icon.fa-microchip {
    color: #dc2626 !important;
}
.nav-tab-active i.fa-microchip,
.nav-tab-active .nav-icon.fa-microchip {
    color: #ffffff !important;
}

/* Barra de Navegación Inferior Móvil (Thumb-Zone Friendly) */
.mobile-bottom-dock,
#mobileBottomDock {
    position: fixed;
    bottom: 0;
    inset-x: 0;
    z-index: 45;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.95);
    padding-bottom: calc(0.55rem + var(--sab));
    padding-top: 0.5rem;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
}

.mobile-dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    color: #64748b;
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--font-tech);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    touch-action: manipulation;
    border-radius: 14px;
    position: relative;
}

.mobile-dock-btn i {
    font-size: 1.35rem;
    transition: transform 0.2s ease;
}

.mobile-dock-btn.active {
    color: #3b82f6;
}

.mobile-dock-btn.active i {
    transform: scale(1.15);
    color: #60a5fa;
}

.mobile-dock-btn:active {
    transform: scale(0.92);
    background: rgba(37, 99, 235, 0.12);
}

/* Botón flotante de WhatsApp adaptado y con gran visibilidad táctil */
@media (max-width: 767px) {
    .floating-whatsapp-btn,
    a[title="Contactar por WhatsApp"] {
        bottom: calc(5.25rem + var(--sab)) !important;
        right: 1.15rem !important;
        width: 3.75rem !important;
        height: 3.75rem !important;
    }
    .floating-whatsapp-btn i,
    a[title="Contactar por WhatsApp"] i {
        font-size: 1.95rem !important;
    }
}

/* ==========================================================================
   4. OBJETIVOS TÁCTILES Y ACCESIBILIDAD (TOUCH TARGETS)
   ========================================================================== */
.touch-target,
.nav-item-btn,
button,
a.btn-touch {
    min-height: var(--tap-min-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

#mobileMenuBtn {
    min-width: 44px;
    min-height: 44px;
}

#mobileMenu button,
#mobileMenu a {
    min-height: 48px;
}

/* Inputs y Selects móviles: tamaño de fuente mínimo 16px para evitar auto-zoom en iOS */
@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Anillos de foco accesibles */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 2px;
}

/* ==========================================================================
   5. COMPONENTES VISUALES DARK TECH
   ========================================================================== */
.glass-panel {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.95);
    color: #1e293b;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.glass-panel-light {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

.cyber-grid {
    background-image: linear-gradient(to right, rgba(226, 232, 240, 0.5) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(226, 232, 240, 0.5) 1px, transparent 1px);
    background-size: 32px 32px;
}

.lcd-screen {
    background: #0f2b18;
    color: #4ade80;
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
    font-family: var(--font-mono);
    border: 2px solid #166534;
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.85);
}

.led-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.led-green.active {
    background-color: #22c55e;
    box-shadow: 0 0 10px #22c55e, 0 0 20px #22c55e;
}

.led-red.active {
    background-color: #ef4444;
    box-shadow: 0 0 10px #ef4444, 0 0 20px #ef4444;
    animation: pulse-danger 1s infinite alternate;
}

.led-yellow.active {
    background-color: #eab308;
    box-shadow: 0 0 10px #eab308, 0 0 20px #eab308;
    animation: pulse-warn 1.5s infinite alternate;
}

.led-off {
    background-color: #334155;
    box-shadow: none;
}

@keyframes pulse-danger {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

@keyframes pulse-warn {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* ==========================================================================
   6. CONTENEDORES RESPONSIVOS CON SCROLL HORIZONTAL SUAVE
   ========================================================================== */
.table-responsive-wrapper,
.scroll-x-touch {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Barra de scroll delgada y elegante en listas internas */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(51, 65, 85, 0.8);
    border-radius: 8px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 1);
}

/* ==========================================================================
   7. ADAPTACIÓN ESPECÍFICA PARA PANTALLAS PEQUEÑAS Y MEDIANAS (MÓVIL Y TABLET)
   ========================================================================== */
@media (max-width: 1023px) {
    /* Ajuste de espaciado en la parte inferior para que la barra dock no tape contenido */
    body {
        padding-bottom: calc(5.25rem + var(--sab));
    }

    /* Elevación de legibilidad global para clases de texto compacto */
    .text-xs {
        font-size: 0.85rem !important;
        line-height: 1.52 !important;
    }
    .text-sm {
        font-size: 0.96rem !important;
        line-height: 1.55 !important;
    }
    .text-base {
        font-size: 1.08rem !important;
        line-height: 1.6 !important;
    }

    /* Ajustes tipográficos fluidos con presencia visual destacada */
    h1, .h1-responsive {
        font-size: clamp(1.85rem, 5.8vw, 2.75rem) !important;
        line-height: 1.25;
    }
    h2, .h2-responsive {
        font-size: clamp(1.45rem, 5vw, 2.25rem) !important;
        line-height: 1.3;
    }
    h3, .h3-responsive {
        font-size: clamp(1.25rem, 4.2vw, 1.85rem) !important;
        line-height: 1.35;
    }

    /* Padding de sección optimizado para pulgar */
    .section-mobile-padding {
        padding-top: 5.5rem;
        padding-bottom: 3rem;
    }

    /* Modal adaptado a pantalla completa o tarjeta ergonómica en teléfonos pequeños */
    .modal-responsive {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        margin: 0.5rem !important;
        display: flex;
        flex-direction: column;
    }

    /* Capa de contraste reforzada en móviles para textos de portada */
    .hero-mobile-protection-layer {
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.94) 75%, rgba(255, 255, 255, 0.85) 100%);
    }

    /* Chips de filtro de cursos táctiles con espaciado amplio y fuente legible */
    .course-filter-btn {
        padding: 0.65rem 1.15rem !important;
        font-size: 0.88rem !important;
        white-space: nowrap;
        flex-shrink: 0;
        border-radius: 0.875rem !important;
    }
}

/* ==========================================================================
   8. TABLETS Y PANTALLAS MEDIANAS (640px - 1023px)
   ========================================================================== */
@media (min-width: 640px) and (max-width: 1023px) {
    .section-mobile-padding {
        padding-top: 6.5rem;
        padding-bottom: 3.5rem;
    }

    /* En tabletas, asegurar tarjetas de cursos y servicios con buena holgura */
    .course-card-item {
        border-radius: 1.5rem !important;
    }
}

/* ==========================================================================
   9. ESCRITORIO Y PANTALLAS GRANDES (1024px+)
   ========================================================================== */
@media (min-width: 1024px) {
    .hero-portada-bg {
        opacity: 1;
    }
    
    .nav-item-btn {
        font-size: 0.98rem !important;
        padding: 0.65rem 1.15rem !important;
    }
}

/* ==========================================================================
   10. UTILIDADES DE ANIMACIÓN, RENDIMIENTO Y EXPERIENCIA MÓVIL FLUIDA
   ========================================================================== */
.will-change-transform {
    will-change: transform, opacity;
}

@keyframes spaFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spa-section:not(.hidden) {
    animation: spaFadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (max-width: 767px) {
    .hero-scroll-track {
        height: 240vh;
        min-height: 1500px;
    }

    /* Mejora legibilidad de etiquetas pequeñas en celular */
    .text-\[10px\],
    .text-\[11px\] {
        font-size: 0.78rem !important;
        line-height: 1.4 !important;
    }

    .mobile-dock-btn {
        min-height: 52px;
        padding: 8px 4px;
    }
}

/* Transición suave al presionar botones sin destello táctil en móvil */
button, .nav-item-btn, a {
    -webkit-tap-highlight-color: transparent;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, transform 0.14s ease, box-shadow 0.18s ease;
}

button:active:not(:disabled),
.nav-item-btn:active,
a:active {
    transform: scale(0.97);
}
