/**
 * iOS Safari CSS Fixes
 * Addresses common iOS Safari styling issues
 */

/* Only apply these fixes for iOS Safari */
@supports (-webkit-touch-callout: none) {
    /* Fix 1: Prevent horizontal scrolling issues */
    html, body {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
        position: relative;
        width: 100%;
    }
    
    /* Fix 2: Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    /* Fix 3: Prevent tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection for specific elements */
    input, textarea, [contenteditable] {
        -webkit-user-select: text;
        -khtml-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
    
    /* Fix 4: Prevent momentum scrolling issues */
    .mainBlocksWrapper,
    .template-content {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
    
    /* Fix 5: Optimize images for iOS */
    img {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix 6: Prevent fixed positioning issues */
    .fixed,
    [style*="position: fixed"] {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix 7: Optimize animations */
    * {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Fix 8: Prevent viewport issues */
    .modal,
    .modal-dialog {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Fix 9: Optimize scrolling containers */
    .scroll-container,
    [data-scroll] {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    /* Fix 10: Prevent text size adjustment */
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Fix 11: Optimize button interactions */
    button,
    .btn,
    [role="button"] {
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Fix 12: Prevent layout shifts */
    .lazyload,
    .lazyloading {
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .lazyloaded {
        opacity: 1;
    }
    
    /* Fix 13: Optimize form elements */
    form {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix 14: Prevent iOS Safari specific bugs */
    .slick-slider,
    .carousel {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Fix 15: Optimize navigation */
    nav,
    .navigation {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix 16: Prevent iOS Safari rendering issues */
    .widget,
    .element {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* Fix 17: Optimize iframe handling */
    iframe {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix 18: Prevent iOS Safari memory issues */
    .hidden,
    [style*="display: none"] {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Fix 19: Optimize touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Fix 20: Prevent iOS Safari specific layout issues */
    .container,
    .row,
    .col {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Additional fixes for iOS Safari 14+ */
@supports (-webkit-touch-callout: none) and (not (overflow: -webkit-marquee)) {
    /* Fix for newer iOS versions */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
} 