/* Mobile & Cross-Browser Compatibility CSS */
/* Ensures perfect display on iOS, Android, and all browsers */

/* ==================== */
/* 1. CSS Variables Fallbacks for older browsers */
/* ==================== */
:root {
    /* Using custom properties with fallbacks */
    --primary-green: #6366f1;
    --primary-green-hover: #8b5cf6;
    --dark-bg: #121212;
    --dark-bg-secondary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --border-color: #282828;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s ease;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    
    /* iOS Safari viewport fix */
    --vh: 1vh;
}

/* ==================== */
/* 2. Universal Mobile Reset */
/* ==================== */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* iOS Safari specific */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    /* Prevent overscroll bounce */
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    
    /* iOS Safari safe areas */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ==================== */
/* 3. Touch Device Optimizations */
/* ==================== */
.touch-device button,
.touch-device a,
.touch-device .btn {
    /* Larger touch targets for mobile */
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
}

/* Remove hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    button:hover,
    a:hover {
        transform: none;
    }
}

/* ==================== */
/* 4. iOS Safari Fixes */
/* ==================== */
/* Fix 100vh on mobile browsers */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .hero {
        min-height: calc(var(--vh, 1vh) * 100);
        min-height: -webkit-fill-available;
    }
}

/* Prevent iOS zoom on input focus */
input,
select,
textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
}

/* iOS input styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
select,
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 8px;
}

/* Remove iOS button styling */
button,
input[type="submit"],
input[type="button"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ==================== */
/* 5. Modal Fixes for Mobile */
/* ==================== */
.modal {
    /* iOS Safari position fix */
    position: fixed !important;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    /* Prevent content from going under notch */
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(var(--vh, 1vh) * 100 - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* Mobile modal scrolling */
@media (max-width: 768px) {
    .modal-content {
        max-height: 90vh;
        max-height: calc(var(--vh, 1vh) * 90);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==================== */
/* 6. Cart Sidebar Mobile */
/* ==================== */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
        
        /* iOS Safari safe area */
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .cart-sidebar.active {
        right: 0;
    }
}

/* ==================== */
/* 7. Flexbox Fallbacks */
/* ==================== */
.nav-links {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.products-grid,
.features-grid,
.testimonials-grid {
    display: -ms-grid;
    display: grid;
}

/* ==================== */
/* 8. Transform Prefixes */
/* ==================== */
.btn {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    
    -webkit-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.product-card {
    -webkit-transform: scale(1);
    -ms-transform: scale(1);
    transform: scale(1);
}

/* ==================== */
/* 9. Gradient Fallbacks */
/* ==================== */
.gradient-text {
    background: -webkit-linear-gradient(45deg, #6366f1, #8b5cf6);
    background: -o-linear-gradient(45deg, #6366f1, #8b5cf6);
    background: linear-gradient(45deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==================== */
/* 10. Backdrop Filter Fallback */
/* ==================== */
.navbar {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(10px)) {
    .navbar {
        background: rgba(18, 18, 18, 0.95);
    }
}

/* ==================== */
/* 11. Scrollbar Styling (Webkit) */
/* ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bg-secondary, #1a1a1a);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-green, #1DB954);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green-hover, #1ED760);
}

/* ==================== */
/* 12. Sticky Position Fallback */
/* ==================== */
.navbar {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}

/* ==================== */
/* 13. Grid Fallbacks for older browsers */
/* ==================== */
@supports not (display: grid) {
    .products-grid,
    .features-grid,
    .testimonials-grid {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    }
    
    .product-card,
    .feature-card,
    .testimonial-card {
        -webkit-box-flex: 0;
        -webkit-flex: 0 0 calc(50% - 1rem);
        -ms-flex: 0 0 calc(50% - 1rem);
        flex: 0 0 calc(50% - 1rem);
    }
}

/* ==================== */
/* 14. Object-fit Fallback */
/* ==================== */
.hero-image img {
    -o-object-fit: cover;
    object-fit: cover;
}

/* Fallback for IE/older browsers */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .hero-image img {
        width: 100%;
        height: auto;
    }
}

/* ==================== */
/* 15. Mobile-Specific Responsive */
/* ==================== */
@media (max-width: 768px) {
    /* Prevent text from being too small */
    body {
        font-size: 16px;
    }
    
    /* Stack navigation on mobile */
    .nav-links {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    /* Full-width buttons on mobile */
    .btn,
    button {
        width: 100%;
        max-width: none;
    }
    
    /* Adjust padding for mobile */
    .container,
    .section-container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Larger touch targets */
    .faq-question,
    .btn,
    button,
    a {
        min-height: 48px;
        padding: 12px 16px;
    }
}

/* ==================== */
/* 16. Landscape Tablet Fixes */
/* ==================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .modal-content {
        max-height: 85vh;
        max-height: calc(var(--vh, 1vh) * 85);
    }
}

/* ==================== */
/* 17. Print Styles */
/* ==================== */
@media print {
    .navbar,
    .cart-sidebar,
    .modal-overlay,
    .modal {
        display: none !important;
    }
}

/* ==================== */
/* 18. Reduced Motion Support */
/* ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;
        -webkit-transition-duration: 0.01ms !important;
        -o-transition-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==================== */
/* 19. Focus Visible (Accessibility) */
/* ==================== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-green, #1DB954);
    outline-offset: 2px;
}

/* Remove outline for mouse users */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* ==================== */
/* 20. Android Chrome Address Bar Fix */
/* ==================== */
@supports (-webkit-touch-callout: none) {
    /* CSS for iOS Safari only */
    body {
        height: -webkit-fill-available;
    }
}

/* ==================== */
/* 21. Firefox Specific Fixes */
/* ==================== */
@-moz-document url-prefix() {
    .modal-content {
        scrollbar-width: thin;
        scrollbar-color: var(--primary-green, #1DB954) var(--dark-bg-secondary, #1a1a1a);
    }
}

/* ==================== */
/* 22. Edge/IE Specific */
/* ==================== */
@supports (-ms-ime-align: auto) {
    /* Edge only */
    .gradient-text {
        background: var(--primary-green, #1DB954);
        -webkit-background-clip: initial;
        background-clip: initial;
        -webkit-text-fill-color: initial;
        color: var(--primary-green, #1DB954);
    }
}
