/* 
 * Optimizaciones específicas para dispositivos móviles
 * Mejora la experiencia en smartphones y tablets
 */

/* ============================================
   OPTIMIZACIONES GENERALES PARA MÓVILES
   ============================================ */

/* Mejorar rendimiento táctil */
@media (max-width: 768px) {
    /* Header fijo optimizado para móviles */
    #main-header {
        padding-top: env(safe-area-inset-top, 0px) !important;
        background-color: rgba(15, 23, 42, 0.98) !important;
    }
    
    .h-16.sm\:h-20 {
        height: calc(4rem + env(safe-area-inset-top, 0px)) !important;
    }
    
    /* Aumentar áreas táctiles */
    button, 
    a, 
    input[type="submit"],
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Mejorar espaciado para dedos */
    .flex.flex-wrap.gap-4 {
        gap: 1rem !important;
    }
    
    /* Aumentar tamaño de texto para legibilidad */
    body {
        font-size: 16px;
        line-height: 1.6;
        padding-top: env(safe-area-inset-top, 0px);
    }
    
    /* Optimizar formularios */
    input, select, textarea {
        font-size: 16px !important; /* Previene zoom en iOS */
        padding: 12px !important;
    }
    
    /* Mejorar scroll en iOS */
    .overflow-hidden {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Menú móvil siempre visible */
    .flex.md\:hidden.items-center.space-x-4 a {
        padding: 8px 12px;
        border-radius: 6px;
        transition: all 0.2s ease;
    }
    
    .flex.md\:hidden.items-center.space-x-4 a:hover {
        background-color: rgba(6, 182, 212, 0.1);
    }
}

/* ============================================
   OPTIMIZACIONES ESPECÍFICAS PARA HERO - MEJORADO
   ============================================ */

@media (max-width: 640px) {
    /* Ajustar altura del Hero */
    #hero {
        min-height: 80vh !important;
        padding-top: 2rem !important;
        padding-bottom: 3rem !important;
    }
    
    /* Ajustar título principal */
    #hero h1 {
        font-size: 2rem !important;
        line-height: 1.1 !important;
        margin-bottom: 0.75rem !important;
    }
    
    #hero h1 span {
        font-size: 2.2rem !important;
        display: block;
        margin-top: 0.25rem;
    }
    
    /* Ajustar subtítulo */
    #hero p {
        font-size: 1rem !important;
        line-height: 1.4 !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Optimizar estadísticas - más compactas */
    .flex.flex-wrap.justify-center.md\:justify-start.gap-4.md\:gap-6.mb-8.md\:mb-10 {
        justify-content: center !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .flex.flex-wrap.justify-center.md\:justify-start.gap-4.md\:gap-6.mb-8.md\:mb-10 > div {
        flex: 0 0 auto;
    }
    
    /* Botones optimizados */
    .flex.flex-col.sm\:flex-row.flex-wrap.gap-3.md\:gap-4.mb-12.md\:mb-14 {
        margin-bottom: 1.5rem !important;
    }
    
    .flex.flex-col.sm\:flex-row.flex-wrap.gap-3.md\:gap-4.mb-12.md\:mb-14 a {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Optimizar dispositivos de demostración - más compactos */
    .relative.mt-10.md\:mt-12 {
        margin-top: 1.5rem !important;
    }
    
    .flex.flex-col.sm\:flex-row.items-center.justify-center.gap-6.md\:gap-8 {
        gap: 1rem !important;
    }
    
    .relative.w-36.h-72.sm\:w-40.sm\:h-80.md\:w-44.md\:h-88 {
        width: 35vw !important;
        height: 70vw !important;
    }
    
    .relative.w-48.h-36.sm\:w-56.sm\:h-42.md\:w-60.md\:h-45 {
        width: 45vw !important;
        height: 34vw !important;
    }
    
    /* Texto informativo "Control total" */
    .mb-8.md\:mb-10.text-center {
        margin-bottom: 1rem !important;
    }
    
    .inline-flex.items-center.gap-1\.5.md\:gap-2.text-sm.md\:text-base.text-gray-300 {
        font-size: 0.8125rem !important;
        padding: 0.5rem 0.75rem !important;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    
    .inline-flex.items-center.gap-1\.5.md\:gap-2.text-sm.md\:text-base.text-gray-300 span {
        font-size: 0.8125rem !important;
    }
    
    /* Scroll indicator */
    .absolute.bottom-4.md\:bottom-6 {
        bottom: 1rem !important;
    }
    
    /* Reducir animaciones para mejor rendimiento en móviles */
    .animate-gradient,
    .animate-gradient-text,
    .animate-pulse-slow,
    .animate-pulse-medium,
    .animate-pulse-slower {
        animation-duration: 3s !important;
    }
    
    /* Optimizar texturas para móviles */
    .texture-dots {
        opacity: 0.4 !important;
        animation: none !important;
    }
    
    .texture-lines,
    .texture-grid,
    .texture-scanlines,
    .texture-noise {
        opacity: 0.2 !important;
    }
    
    .connection-particle {
        display: none;
    }
    
    /* Ocultar elementos decorativos menos importantes */
    .connection-line {
        opacity: 0.3;
    }
    
    .absolute.top-1\/4.left-1\/4,
    .absolute.bottom-1\/4.right-1\/4,
    .absolute.top-2\/3.left-2\/3 {
        display: none;
    }
    
    /* Reducir overlay de brillo */
    .bg-gradient-to-tr.from-transparent.via-cyan-500\/5.to-transparent {
        opacity: 0.3;
    }
}

/* Pantallas muy pequeñas (menos de 400px) */
@media (max-width: 400px) {
    #hero h1 {
        font-size: 1.75rem !important;
    }
    
    #hero h1 span {
        font-size: 2rem !important;
    }
    
    #hero p {
        font-size: 0.9375rem !important;
    }
    
    .flex.flex-wrap.justify-center.md\:justify-start.gap-4.md\:gap-6.mb-8.md\:mb-10 {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem !important;
    }
    
    .flex.flex-wrap.justify-center.md\:justify-start.gap-4.md\:gap-6.mb-8.md\:mb-10 > div {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
    
    .relative.w-36.h-72.sm\:w-40.sm\:h-80.md\:w-44.md\:h-88 {
        width: 50vw !important;
        height: 100vw !important;
    }
    
    .relative.w-48.h-36.sm\:w-56.sm\:h-42.md\:w-60.md\:h-45 {
        width: 60vw !important;
        height: 45vw !important;
    }
}

/* ============================================
   OPTIMIZACIONES PARA TABLETS
   ============================================ */

@media (min-width: 641px) and (max-width: 1024px) {
    /* Ajustar título para tablets */
    #hero h1 {
        font-size: 3.5rem !important;
    }
    
    #hero h1 span {
        font-size: 4rem !important;
    }
    
    /* Ajustar layout de dispositivos */
    .flex.flex-col.md\:flex-row {
        flex-direction: column;
        gap: 3rem;
    }
    
    .relative.w-48.h-96,
    .relative.w-64.h-48 {
        width: 60vw !important;
        margin: 0 auto;
    }
    
    .relative.w-48.h-96 {
        height: 120vw !important;
    }
    
    .relative.w-64.h-48 {
        height: 45vw !important;
    }
}

/* ============================================
   MEJORAS DE RENDIMIENTO
   ============================================ */

/* Reducir animaciones en dispositivos con batería baja */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimizar para modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    /* Ajustes sutiles para mejor contraste */
    .bg-gray-800\/50 {
        background-color: rgba(30, 41, 59, 0.7) !important;
    }
    
    .border-gray-700 {
        border-color: rgba(55, 65, 81, 0.8) !important;
    }
}

/* ============================================
   MEJORAS DE ACCESIBILIDAD
   ============================================ */

/* Mejorar contraste para baja visión */
@media (prefers-contrast: high) {
    .text-gray-300 {
        color: #f8fafc !important;
    }
    
    .text-gray-400 {
        color: #cbd5e1 !important;
    }
    
    .border-gray-700 {
        border-color: #475569 !important;
    }
}

/* Soporte para modo lectura */
@media (prefers-color-scheme: light) {
    /* Ajustes para modo claro (si se implementa en el futuro) */
    .dark-mode-only {
        display: none;
    }
}

/* ============================================
   OPTIMIZACIONES PARA ORIENTACIÓN
   ============================================ */

/* Landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    #hero {
        min-height: 100vh;
        padding-top: 4rem;
        padding-bottom: 4rem;
    }
    
    #hero h1 {
        font-size: 2.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    #hero p {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .flex.flex-wrap.gap-8.mb-12 {
        display: none; /* Ocultar estadísticas en landscape */
    }
    
    .relative.mt-20 {
        margin-top: 2rem !important;
    }
    
    .flex.flex-col.md\:flex-row {
        flex-direction: row;
        gap: 1rem;
    }
    
    .relative.w-48.h-96,
    .relative.w-64.h-48 {
        width: 40vw !important;
    }
    
    .relative.w-48.h-96 {
        height: 80vw !important;
    }
    
    .relative.w-64.h-48 {
        height: 30vw !important;
    }
}

/* ============================================
   MEJORAS DE CARGA PROGRESIVA
   ============================================ */

/* Estilos críticos para above-the-fold */
#hero {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
}

/* Priorizar carga de elementos visibles */
#hero .container {
    content-visibility: auto;
}

/* ============================================
   FIXES PARA NAVEGADORES ESPECÍFICOS
   ============================================ */

/* Safari iOS fixes */
@supports (-webkit-touch-callout: none) {
    #hero {
        min-height: -webkit-fill-available;
    }
    
    .h-screen {
        height: -webkit-fill-available;
    }
}

/* Firefox scrollbar styling */
@-moz-document url-prefix() {
    .overflow-hidden {
        scrollbar-width: thin;
        scrollbar-color: #475569 #1e293b;
    }
}

/* ============================================
   MEJORAS DE INTERACCIÓN TÁCTIL
   ============================================ */

/* Feedback táctil mejorado */
@media (hover: none) and (pointer: coarse) {
    button:active,
    a:active,
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #06b6d4;
        outline-offset: 2px;
    }
}

/* Prevenir zoom no deseado en formularios iOS */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ============================================
   OPTIMIZACIONES DE TEXTO
   ============================================ */

/* Mejorar legibilidad en móviles */
@media (max-width: 768px) {
    p, li, span:not(.icon) {
        text-wrap: pretty;
        hyphens: auto;
    }
    
    h1, h2, h3, h4 {
        text-wrap: balance;
    }
}

/* Ajustar interlineado para mejor lectura */
@media (max-width: 768px) {
    .leading-relaxed {
        line-height: 1.6 !important;
    }
    
    .leading-tight {
        line-height: 1.2 !important;
    }
}