/* 
   MOBILE FIX FINAL - DETERMINISTIC V27.1
   RULES: MOBILE ONLY (max-width: 767px)
   TARGET: iPhone 14 (390px), Android (360-430px)
*/

@media (max-width: 767px) {

    /* ==================== GLOBAL SAFETY ==================== */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    * {
        max-width: 100%;
    }

    /* ==================== PERFORMANCE OPTIMIZATIONS ==================== */
    /* Hardware acceleration for smooth animations */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        -webkit-tap-highlight-color: transparent;
    }

    /* Optimize rendering performance */
    .hero,
    .hero-content,
    .mobile-video-bg,
    .hero-title,
    .hero-actions,
    .hero-description-container {
        transform: translateZ(0);
        backface-visibility: hidden;
        perspective: 1000px;
    }

    /* Reduce animation complexity on low-end devices */
    @media (prefers-reduced-motion: reduce) {

        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* ==================== MOBILE VIDEO BACKGROUND ==================== */
    /* Show and position video as fullscreen background */
    .mobile-video-bg {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 0 !important;
        overflow: hidden !important;
    }

    .mobile-bg-video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        will-change: transform;
        transform: translateZ(0);
    }

    .mobile-video-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
        background-size: 30px 30px;
        pointer-events: none;
        box-shadow: inset 0 0 200px rgba(0, 0, 0, 0.9);
    }

    /* Hero section full viewport */
    .hero {
        min-height: 100vh !important;
    }

    /* Ensure hero content floats on top of video */
    .hero .container {
        position: relative !important;
        z-index: 10 !important;
    }

    .hero-content {
        position: relative !important;
        z-index: 10 !important;
        padding-top: 3rem !important;
        padding-bottom: 0.2rem !important;
        min-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important;
    }

    .hero-title {
        text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9) !important;
        order: 1 !important;
        margin-bottom: 1.5rem !important;
    }

    /* Buttons BEFORE description */
    .hero-actions {
        order: 2 !important;
        margin-bottom: 2rem !important;
    }

    /* Description (NOSOTROS) AFTER buttons */
    .hero-description-container {
        order: 3 !important;
        padding: 1.5rem !important;
        text-align: center !important;
    }

    .hero-description,
    .novadex-intro {
        text-align: center !important;
    }

    .hero-description-text {
        text-align: center !important;
    }

    /* Move footer icons inside NOSOTROS card on mobile */
    .hero-footer-unified {
        position: static !important;
        margin-top: 1.5rem !important;
        padding: 0 !important;
    }

    .footer-stats,
    .footer-socials-grid {
        justify-content: center !important;
    }

    .hero {
        display: flex !important;
        flex-direction: column !important;
    }

    .hero .container {
        order: 1 !important;
    }

    .hero-footer-unified {
        order: 2 !important;
        margin-top: -2rem !important;
        padding: 0 1.5rem 1.5rem 1.5rem !important;
    }

    .footer-stats {
        margin-bottom: 1rem !important;
        gap: 0.8rem !important;
    }

    /* Hide desktop 3D animation on mobile */
    .hero-visual,
    .hero-card {
        display: none !important;
    }

    /* CONTINUING MOBILE RULES... */

    /* ==================== NAV TOGGLE ==================== */
    .nav-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10000 !important;
    }

    /* ==================== HERO - REVERTED LOGIC (V27.1) ==================== */
    /* FIX: Remove the "Card" look completely on mobile */
    .hero-card {
        height: auto !important;
        min-height: 360px !important;
        /* REDUCED from 480px to eliminate empty space */
        display: block !important;
        padding-top: 0.5rem !important;
        padding-bottom: 1rem !important;

        /* AGGRESSIVE UN-BOXING */
        background: transparent !important;
        background-color: transparent !important;
        box-shadow: none !important;
        border: none !important;
        backdrop-filter: none !important;
    }

    /* Force 2-line title: Smaller Font + 100% Width */
    .hero-title {
        white-space: normal !important;
        font-size: 1.6rem !important;
        /* REDUCED from 2rem to ensure fit */
        line-height: 1.2 !important;
        max-width: 100% !important;
        /* Allow full width */
        margin: 0 auto 1.5rem !important;
        text-align: center !important;
    }

    .hero-title br {
        display: none !important;
        /* Let new width handle breaks naturally */
    }

    /* Animation: Restore original centering */
    .nova-hud-interface {
        width: 300px !important;
        /* Slightly smaller for safety */
        height: 300px !important;
        margin: 0 auto !important;
        position: relative !important;
        transform: none !important;
        left: auto !important;
        top: auto !important;
    }

    .orbit-center {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 10 !important;
    }

    /* ==================== NOSOTROS - PADDING FIX ==================== */
    .nosotros-card {
        padding: 2.5rem 2rem !important;
        /* INCREASED padding significantly */
        width: auto !important;
        margin: 0 1rem !important;
        box-sizing: border-box !important;
    }

    .nosotros-text {
        padding: 0 1rem !important;
        /* INCREASED from 0.5rem to 1rem */
        line-height: 1.6 !important;
    }

    /* ==================== CONTACT FORM - VISUAL POLISH ==================== */
    #contacto {
        padding: 2rem 0 !important;
    }

    #contacto .container {
        padding: 0 !important;
    }

    #contacto .contact-grid {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .contact-form-wrapper {
        max-width: 94vw !important;
        width: 94vw !important;
        margin: 0 auto !important;
        padding: 2rem 1rem !important;
        background: rgba(15, 23, 42, 0.98) !important;
        /* Darker/Solider */
        border: 1px solid rgba(168, 85, 247, 0.4) !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
        box-sizing: border-box !important;
        height: auto !important;
    }

    /* RESTRUCTURE INPUTS: Stack everything vertically */
    .form-group,
    .input-group,
    .contact-input-group {
        display: block !important;
        width: 100% !important;
        margin-bottom: 1.25rem !important;
        position: relative !important;
    }

    .contact-input,
    .contact-select,
    .contact-textarea {
        width: 100% !important;
        max-width: 100% !important;
        height: 50px !important;
        line-height: normal !important;
        padding: 0.8rem 1rem !important;
        box-sizing: border-box !important;
        font-size: 16px !important;
        /* iOS safe */
        margin: 0 !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 8px !important;
        color: #fff !important;
    }

    .contact-textarea {
        height: 120px !important;
    }

    /* Fix Email/Domain group */
    .email-group {
        display: block !important;
        /* Changed from flex to block for better containment */
        width: 100% !important;
        margin-bottom: 1.25rem !important;
    }

    .email-group input[type="text"],
    .email-group .contact-input {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0.5rem !important;
    }

    .domain-select {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 8px !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        background: rgba(255, 255, 255, 0.05) !important;
        box-sizing: border-box !important;
    }

    /* Labels */
    .contact-label {
        margin-bottom: 0.4rem !important;
        display: block !important;
        font-size: 0.85rem !important;
        color: #e2e8f0 !important;
        font-weight: 500 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    /* ==================== APPS SECTION - 2x2 GRID (KEEP) ==================== */
    #apps {
        padding: 2rem 1rem !important;
        overflow-x: hidden !important;
    }

    .apps-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1rem !important;
        max-width: 94vw !important;
        margin: 0 auto !important;
        overflow-x: hidden !important;
        padding: 0 !important;
    }

    .app-card {
        padding: 1rem !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .app-mockup {
        transform: scale(0.7) !important;
        margin: 0 auto !important;
    }

    .app-info h3 {
        font-size: 0.95rem !important;
    }

    .app-desc {
        font-size: 0.8rem !important;
        line-height: 1.4 !important;
    }

    /* ==================== FOOTER - COMPACT ROWS ==================== */
    .nova-footer {
        padding: 2rem 1rem !important;
    }

    .footer-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .footer-main-row {
        flex-direction: column !important;
        align-items: center !important;
        gap: 2rem !important;
    }

    .footer-center {
        order: -1 !important;
        width: 100% !important;
        text-align: center !important;
    }

    .footer-center .nav-logo {
        height: 60px !important;
        margin-bottom: 1rem !important;
    }

    .footer-left {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
        text-align: center !important;
    }

    .footer-left>div {
        min-width: 0 !important;
    }

    .footer-left h3 {
        font-size: 0.9rem !important;
        margin-bottom: 0.75rem !important;
    }

    .footer-left a {
        font-size: 0.85rem !important;
        display: block !important;
        margin-bottom: 0.5rem !important;
    }

    .footer-right {
        width: 100% !important;
        text-align: center !important;
    }

    .footer-right h3 {
        font-size: 0.9rem !important;
        margin-bottom: 0.75rem !important;
    }

    .footer-social-row {
        justify-content: center !important;
        gap: 1rem !important;
    }

    .footer-bottom-bar {
        flex-direction: column !important;
        gap: 1rem !important;
        text-align: center !important;
        padding-top: 1.5rem !important;
        font-size: 0.8rem !important;
    }

    /* ==================== PERFORMANCE ==================== */
    * {
        will-change: auto !important;
    }

    .ai-orbit-system,
    .animated,
    .orbit {
        will-change: transform !important;
    }

}