/* ===== MOBILE-SPECIFIC OPTIMIZATIONS ===== */

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .hero-section {
        min-height: 100vh; /* 100vh */
        min-height: calc(var(--vh, 1vh) * 100);
        padding-top: 6rem !important;
    }
    
    .navbar {
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
    }
    
    /* Fix for iOS Safari address bar */
    .full-height {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
}

/* Android Chrome specific optimizations */
@media (max-width: 768px) {
    /* Improve tap responsiveness on Android */
    .btn, .nav-link, .card {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.3);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Prevent text selection on cards */
    .feature-card, .pricing-card {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection in form inputs */
    input, textarea, .selectable-text {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
}

/* Mobile font optimization */
@media (max-width: 768px) {
    /* Improve Arabic text rendering on mobile */
    body, h1, h2, h3, h4, h5, h6 {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        font-feature-settings: "kern" 1;
    }
    
    /* Improve RTL text layout */
    [dir="rtl"] {
        text-align: right;
        direction: rtl;
    }
    
    [dir="rtl"] .text-center {
        text-align: center !important;
    }
}

/* Mobile-specific animations */
@media (max-width: 768px) {
    /* Faster, lighter animations for mobile */
    .mobile-device .feature-card,
    .mobile-device .pricing-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .mobile-device .btn {
        transition: all 0.15s ease;
    }
    
    /* Disable complex animations on low-end devices */
    @media (max-width: 480px) {
        .hero-section::before,
        .logo-glow,
        .screen-glow {
            display: none !important;
        }
        
        * {
            animation-duration: 0.2s !important;
            transition-duration: 0.2s !important;
        }
    }
}

/* Mobile keyboard adjustments */
@media (max-width: 768px) {
    /* Adjust layout when virtual keyboard is shown */
    .keyboard-open .hero-section {
        height: 50vh;
        min-height: 300px;
    }
    
    .keyboard-open .navbar {
        position: relative;
    }
    
    /* Form container adjustments */
    .support-form-container {
        margin-bottom: 2rem;
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile touch gestures */
@media (max-width: 768px) {
    /* Swipeable cards */
    .swipeable {
        touch-action: pan-x;
        position: relative;
        overflow: hidden;
    }
    
    .swipeable::after {
        content: "⬅️ اسحب للتصفح ➡️";
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px;
        color: rgba(0, 0, 0, 0.4);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .swipeable:hover::after {
        opacity: 1;
    }
}

/* Mobile-specific loading states */
@media (max-width: 768px) {
    .mobile-loading {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 9999;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-radius: 15px;
        padding: 2rem;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-loading .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid var(--primary-color);
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin: 0 auto 1rem;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
}

/* Mobile accessibility improvements */
@media (max-width: 768px) {
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .feature-card,
        .pricing-card {
            border: 2px solid #000;
            background: #fff;
            color: #000;
        }
        
        .btn-primary {
            background: #000;
            border-color: #000;
            color: #fff;
        }
        
        .text-muted {
            color: #333 !important;
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
        
        .hero-section::before,
        .logo-glow {
            display: none !important;
        }
    }
    
    /* Large text support */
    @media (prefers-reduced-data: reduce) {
        .hero-section::before,
        .logo-glow,
        .screen-glow {
            display: none;
        }
        
        [data-aos] {
            transform: none !important;
            opacity: 1 !important;
        }
    }
}

/* Mobile print optimizations */
@media print and (max-width: 768px) {
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .navbar,
    .download-buttons,
    .social-links {
        display: none !important;
    }
    
    .feature-card,
    .pricing-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        border: 1px solid #ccc;
        padding: 1rem;
    }
    
    .hero-section {
        page-break-after: always;
    }
}

/* Mobile PWA enhancements */
@media (display-mode: standalone) {
    /* PWA-specific styles */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .navbar {
        padding-top: calc(env(safe-area-inset-top) + 0.5rem);
    }
    
    .hero-section {
        margin-top: calc(env(safe-area-inset-top) + 60px);
    }
    
    /* Hide browser UI elements in PWA */
    .pwa-hidden {
        display: none;
    }
    
    /* Add PWA-specific branding */
    .pwa-badge {
        position: fixed;
        top: env(safe-area-inset-top, 10px);
        right: 10px;
        background: var(--primary-color);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 10px;
        z-index: 1000;
    }
}

/* Mobile network-aware styles */
@media (max-width: 768px) {
    /* Reduce visual complexity for slow connections */
    .slow-connection .hero-section::before,
    .slow-connection .logo-glow,
    .slow-connection .screen-glow,
    .slow-connection [data-aos] {
        display: none !important;
    }
    
    .slow-connection .feature-card,
    .slow-connection .pricing-card {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    .slow-connection * {
        transition: none !important;
        animation: none !important;
    }
}

/* Mobile-specific utility classes */
@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
    
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-no-padding {
        padding: 0 !important;
    }
    
    .mobile-small-padding {
        padding: 0.5rem !important;
    }
    
    .mobile-large-padding {
        padding: 2rem !important;
    }
}

/* Very small devices (320px and down) */
@media (max-width: 320px) {
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .feature-card,
    .pricing-card {
        padding: 1rem 0.5rem;
        margin-bottom: 1rem;
    }
    
    .btn {
        font-size: 14px;
        padding: 10px 16px;
        min-height: 44px;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    .hero-logo {
        width: 100px !important;
        height: 100px !important;
    }
    
    .logo-showcase {
        padding: 0.5rem !important;
        max-width: 200px;
    }
}

/* Mobile performance monitoring */
@media (max-width: 768px) {
    /* Critical rendering path optimization */
    .above-fold {
        contain: layout style paint;
    }
    
    .below-fold {
        contain: strict;
        content-visibility: auto;
        contain-intrinsic-size: 500px;
    }
    
    /* Reduce repaints */
    .mobile-device .feature-card,
    .mobile-device .pricing-card {
        will-change: transform;
        transform: translateZ(0);
    }
    
    .mobile-device .btn:active {
        transform: scale(0.95) translateZ(0);
    }
}

/* Enhanced Footer Mobile Layout */
@media (max-width: 768px) {
    /* Override footer improvements with better mobile layout */
    footer .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Better grid layout for footer links */
    footer .col-lg-2 ul,
    footer .col-lg-3 ul {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.8rem !important;
        justify-items: center !important;
        max-width: 280px !important;
        margin: 0 auto !important;
    }
    
    footer .col-lg-2 ul li,
    footer .col-lg-3 ul li {
        width: 100% !important;
        text-align: center !important;
    }
    
    footer .col-lg-2 ul li a,
    footer .col-lg-3 ul li a {
        display: block !important;
        padding: 0.6rem 0.4rem !important;
        border-radius: 8px !important;
        font-size: 14px !important;
        transition: all 0.2s ease !important;
        border: 1px solid transparent !important;
    }
    
    footer .col-lg-2 ul li a:hover,
    footer .col-lg-3 ul li a:hover {
        background: rgba(37, 99, 235, 0.15) !important;
        border-color: rgba(37, 99, 235, 0.3) !important;
        color: #fbbf24 !important;
        transform: translateY(-1px) !important;
    }
    
    /* Enhanced social links */
    .social-links {
        display: flex !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 1.2rem !important;
        margin: 2rem auto !important;
        padding: 1rem 0 !important;
    }
    
    .social-links a {
        width: 54px !important;
        height: 54px !important;
        font-size: 22px !important;
        border: 2px solid rgba(255, 255, 255, 0.2) !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        position: relative !important;
        overflow: hidden !important;
    }
    
    .social-links a::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
        transition: left 0.5s ease;
    }
    
    .social-links a:hover::before {
        left: 100%;
    }
    
    .social-links a:hover {
        background: var(--primary-color) !important;
        border-color: var(--primary-color) !important;
        transform: translateY(-4px) scale(1.05) !important;
        box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4) !important;
    }
    
    /* Footer bottom improvements */
    footer hr {
        margin: 2.5rem 0 1.5rem !important;
        border-color: rgba(255, 255, 255, 0.15) !important;
        border-width: 1px !important;
    }
    
    footer .row.align-items-center {
        flex-direction: column !important;
        gap: 1.2rem !important;
        padding: 0 1rem !important;
    }
    
    footer .row.align-items-center p {
        font-size: 15px !important;
        color: #cbd5e1 !important;
        margin: 0 !important;
        font-weight: 400 !important;
    }
    
    footer .row.align-items-center small {
        font-size: 14px !important;
        color: #94a3b8 !important;
        margin: 0 !important;
    }
    
    footer .row.align-items-center small a {
        color: #fbbf24 !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        padding: 0.2rem 0.4rem !important;
        border-radius: 4px !important;
        transition: all 0.2s ease !important;
    }
    
    footer .row.align-items-center small a:hover {
        background: rgba(251, 191, 36, 0.1) !important;
        color: #fcd34d !important;
    }
}

/* Very small screens footer */
@media (max-width: 480px) {
    footer {
        padding: 2rem 0 1rem !important;
    }
    
    footer .col-lg-4 p {
        font-size: 14px !important;
        max-width: 280px !important;
        padding: 0 0.5rem !important;
    }
    
    footer .col-lg-2 ul,
    footer .col-lg-3 ul {
        grid-template-columns: 1fr !important;
        max-width: 200px !important;
    }
    
    .social-links {
        gap: 1rem !important;
    }
    
    .social-links a {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }
} 