/**
 * MOBILE ENHANCED V2 - Serene Space AI
 * Advanced mobile optimizations for today's launch
 * Fixes: Performance, Touch, Readability, Dark Theme
 */

/* ========================================
   CRITICAL MOBILE FIXES
   ======================================== */

/* Fix: Remove X-Frame-Options meta tag error (should be HTTP header only) */
/* This is already in HTML - needs server-side fix, not CSS */

/* Fix: Ensure proper viewport on all devices */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* Fix: Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents iOS zoom */
    }
}

/* ========================================
   DARK THEME MOBILE OVERRIDES
   ======================================== */

@media (max-width: 768px) {
    /* Ensure hero and dark sections have WHITE text */
    .hero-section,
    .hero-section h1,
    .hero-section h2,
    .hero-section p,
    .hero-subtitle,
    [class*="hero"] {
        color: #ffffff !important;
    }
    
    /* Dark background sections = white text */
    .resources-section,
    .why-coaching-works,
    .demo-section,
    .problem-section,
    .how-it-works,
    .features-section,
    .coaches-section,
    .trust-section {
        background: var(--dark-navy, #001a33);
        color: #ffffff;
    }
    
    .resources-section *:not(.btn-primary):not(.btn-secondary),
    .why-coaching-works *:not(.btn-primary):not(.btn-secondary),
    .demo-section *:not(.btn-primary):not(.btn-secondary),
    .problem-section *:not(.btn-primary):not(.btn-secondary),
    .how-it-works *:not(.btn-primary):not(.btn-secondary),
    .features-section *:not(.btn-primary):not(.btn-secondary),
    .coaches-section *:not(.btn-primary):not(.btn-secondary),
    .trust-section *:not(.btn-primary):not(.btn-secondary) {
        color: #ffffff;
    }
    
    /* Light background sections = dark text */
    .comparison-section,
    .faq-section,
    .privacy-section {
        background: #ffffff;
        color: #1e293b;
    }
    
    .comparison-section *:not(.btn-primary):not(.btn-secondary),
    .faq-section *:not(.btn-primary):not(.btn-secondary),
    .privacy-section *:not(.btn-primary):not(.btn-secondary) {
        color: #1e293b !important;
    }
}

/* ========================================
   MOBILE TOUCH IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Larger touch targets (WCAG AA: min 44x44px) */
    button,
    a.btn-primary,
    a.btn-secondary,
    .cta-button,
    .nav-links a {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 24px;
    }
    
    /* Better tap feedback */
    button:active,
    a:active {
        transform: scale(0.97);
        opacity: 0.9;
        transition: all 0.1s ease;
    }
    
    /* Remove hover states on touch */
    @media (hover: none) {
        button:hover,
        a:hover {
            transform: none;
            opacity: 1;
        }
    }
    
    /* Better tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(102, 217, 255, 0.3);
        tap-highlight-color: rgba(102, 217, 255, 0.3);
    }
}

/* ========================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Disable expensive animations on mobile */
    *,
    *::before,
    *::after {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Optimize scrolling */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reduce box shadows for performance */
    .card,
    .pricing-card,
    .feature-card,
    .testimonial-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* GPU acceleration for smooth scrolling */
    section,
    .card,
    .modal {
        will-change: transform;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* ========================================
   MOBILE NAVIGATION FIXES
   ======================================== */

@media (max-width: 768px) {
    /* Ensure navbar doesn't overlap content */
    body {
        padding-top: 70px !important;
    }
    
    /* Fixed navbar */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #001a33;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    /* Mobile menu overlay */
    .nav-links.active {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 26, 51, 0.98);
        backdrop-filter: blur(10px);
        z-index: 999;
        overflow-y: auto;
        padding: 30px 20px;
    }
    
    .nav-links.active a {
        color: #ffffff;
        font-size: 1.2rem;
        padding: 15px 10px;
        border-bottom: 1px solid rgba(102, 217, 255, 0.2);
    }
}

/* ========================================
   MOBILE HERO SECTION
   ======================================== */

@media (max-width: 768px) {
    .hero-section {
        padding: 100px 20px 60px;
        min-height: auto;
    }
    
    .hero-content h1 {
        font-size: 2.2rem !important;
        line-height: 1.2;
        margin-bottom: 20px;
        color: #ffffff !important;
    }
    
    .hero-subtitle {
        font-size: 1.1rem !important;
        line-height: 1.6;
        color: #ffffff !important;
        margin-bottom: 30px;
    }
    
    /* Hero buttons stack */
    .hero-cta {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }
    
    .hero-cta .btn-large {
        width: 100%;
        font-size: 1.1rem;
        padding: 16px 30px;
    }
    
    /* Hero badge/stats */
    .hero-stats {
        flex-direction: column;
        gap: 15px;
        margin-top: 40px;
    }
    
    .stat-card {
        width: 100%;
        padding: 20px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        backdrop-filter: blur(10px);
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.9rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
}

/* ========================================
   MOBILE FOOTER OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    footer {
        padding: 50px 20px 30px;
        background: #001a33;
        color: #ffffff;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .footer-column {
        text-align: center;
    }
    
    .footer-column h4 {
        color: #66d9ff;
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .footer-column a {
        color: #ffffff;
        font-size: 0.95rem;
        display: block;
        padding: 8px 0;
    }
    
    .footer-column a:hover {
        color: #66d9ff;
    }
    
    .trust-badges {
        flex-direction: column;
        gap: 10px;
        margin-top: 30px;
    }
    
    .trust-badge {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 10px 15px;
        font-size: 0.85rem;
        background: rgba(102, 217, 255, 0.1);
        border: 1px solid rgba(102, 217, 255, 0.3);
        border-radius: 8px;
        text-align: center;
    }
    
    .copyright {
        text-align: center;
        font-size: 0.85rem;
        color: rgba(255, 255, 255, 0.7);
        margin-top: 30px;
        padding-top: 20px;
        border-top: 1px solid rgba(102, 217, 255, 0.2);
    }
}

/* ========================================
   MOBILE FAQ SECTION
   ======================================== */

@media (max-width: 768px) {
    .faq-section {
        padding: 60px 20px;
        background: #ffffff;
    }
    
    .faq-section h2 {
        color: #001a33;
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .faq-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .faq-item {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 20px;
    }
    
    .faq-question {
        font-size: 1.05rem;
        font-weight: 600;
        color: #001a33 !important;
        line-height: 1.5;
        padding-right: 30px;
    }
    
    .faq-answer {
        font-size: 0.95rem;
        color: #334155 !important;
        line-height: 1.7;
        margin-top: 12px;
    }
    
    .faq-answer p {
        color: #334155 !important;
    }
}

/* ========================================
   MOBILE PRICING/COMPARISON SECTION
   ======================================== */

@media (max-width: 768px) {
    .comparison-section {
        padding: 60px 20px;
        background: #ffffff;
    }
    
    .comparison-section h2,
    .comparison-section h3 {
        color: #001a33 !important;
    }
    
    .comparison-section p,
    .comparison-section li {
        color: #334155 !important;
    }
    
    .pricing-comparison {
        flex-direction: column;
        gap: 20px;
    }
    
    .pricing-card {
        width: 100%;
        padding: 30px 20px;
    }
    
    /* Comparison table scrollable */
    .comparison-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -20px;
        padding: 0 20px;
    }
    
    .comparison-table {
        min-width: 600px;
    }
    
    .comparison-table th,
    .comparison-table td {
        font-size: 0.9rem;
        padding: 12px 10px;
        color: #1e293b !important;
    }
}

/* ========================================
   MOBILE FORMS & INPUTS
   ======================================== */

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 20px;
    }
    
    label {
        font-size: 1rem;
        font-weight: 500;
        color: #1e293b;
        margin-bottom: 8px;
        display: block;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        width: 100%;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 14px;
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        background: #ffffff;
        color: #1e293b;
        transition: border-color 0.2s;
    }
    
    input:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: #66d9ff;
        box-shadow: 0 0 0 3px rgba(102, 217, 255, 0.1);
    }
    
    /* Submit buttons full width */
    button[type="submit"],
    input[type="submit"] {
        width: 100%;
        font-size: 1.1rem;
        padding: 16px;
        background: #66d9ff;
        color: #001a33;
        font-weight: 600;
        border: none;
        border-radius: 8px;
        cursor: pointer;
    }
    
    button[type="submit"]:active {
        transform: scale(0.98);
    }
}

/* ========================================
   MOBILE CHAT WIDGET
   ======================================== */

@media (max-width: 768px) {
    /* Tawk.to widget mobile positioning */
    #tawkchat-container {
        bottom: 15px !important;
        right: 15px !important;
    }
    
    .fallback-chat-button {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: #66d9ff;
        color: #001a33;
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        z-index: 998;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }
    
    .fallback-chat-button:active {
        transform: scale(0.95);
    }
}

/* ========================================
   MOBILE MODALS/POPUPS
   ======================================== */

@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        padding: 30px 20px;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px;
    }
    
    .modal-header h2 {
        font-size: 1.6rem;
        color: #001a33;
    }
    
    .modal-body {
        font-size: 1rem;
        line-height: 1.6;
        color: #334155;
    }
    
    .modal-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 50%;
    }
}

/* ========================================
   MOBILE CARDS & GRIDS
   ======================================== */

@media (max-width: 768px) {
    /* All grids stack on mobile */
    .benefits-grid,
    .features-grid,
    .steps-grid,
    .testimonials-grid,
    .pricing-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    /* Cards optimized for mobile */
    .card,
    .feature-card,
    .benefit-card {
        padding: 25px 20px;
        border-radius: 12px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
    }
    
    .card-title {
        font-size: 1.2rem;
        color: #001a33;
        margin-bottom: 12px;
    }
    
    .card-description {
        font-size: 0.95rem;
        color: #334155;
        line-height: 1.6;
    }
}

/* ========================================
   MOBILE TYPOGRAPHY
   ======================================== */

@media (max-width: 768px) {
    /* Optimized font sizes for mobile */
    h1 {
        font-size: 2rem;
        line-height: 1.2;
        font-weight: 700;
    }
    
    h2 {
        font-size: 1.75rem;
        line-height: 1.3;
        font-weight: 600;
    }
    
    h3 {
        font-size: 1.4rem;
        line-height: 1.4;
        font-weight: 600;
    }
    
    h4 {
        font-size: 1.2rem;
        font-weight: 600;
    }
    
    p {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    .lead {
        font-size: 1.1rem;
        line-height: 1.6;
    }
    
    small,
    .small-text {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
}

/* ========================================
   MOBILE ACCESSIBILITY
   ======================================== */

@media (max-width: 768px) {
    /* Better focus indicators for mobile */
    *:focus {
        outline: 3px solid #66d9ff;
        outline-offset: 2px;
    }
    
    /* Skip to content link for keyboard users */
    .skip-to-content {
        position: absolute;
        top: -100px;
        left: 0;
        background: #66d9ff;
        color: #001a33;
        padding: 12px 20px;
        z-index: 10000;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
    
    /* Ensure sufficient color contrast */
    a {
        color: #0066cc;
        text-decoration: underline;
    }
    
    a:visited {
        color: #551a8b;
    }
}

/* ========================================
   MOBILE LANDSCAPE MODE
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 60px 20px 40px;
    }
    
    .modal-content {
        max-height: 80vh;
    }
    
    .navbar {
        padding: 8px 0;
    }
}

/* ========================================
   VERY SMALL SCREENS (iPhone SE, etc.)
   ======================================== */

@media (max-width: 375px) {
    .container {
        padding: 0 16px;
    }
    
    h1 {
        font-size: 1.6rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    .btn-primary,
    .btn-secondary {
        font-size: 0.95rem;
        padding: 14px 20px;
    }
}

/* ========================================
   MOBILE SAFE AREA (iPhone X/11/12/13/14)
   ======================================== */

@media (max-width: 768px) {
    /* iOS safe area support */
    @supports (padding: max(0px)) {
        body {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
        
        .navbar,
        footer {
            padding-left: max(20px, env(safe-area-inset-left));
            padding-right: max(20px, env(safe-area-inset-right));
        }
    }
}
