/* iOS Theme Fixes for iPhone */

/* Fix iOS form input rendering */
@supports (-webkit-touch-callout: none) {
    /* Prevent iOS from applying default styles */
    input, textarea, select, button {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Fix theme selector on iOS */
    .theme-selector-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Fix dropdown on iOS */
    .theme-dropdown {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ensure colors are properly rendered on iOS */
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
    }
    
    /* Fix background colors not applying correctly */
    .hero-section,
    .nav-framer,
    .analysis-card,
    .feature-card,
    .job-card,
    .modal-content {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix input backgrounds on iOS */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        background-color: var(--input-bg) !important;
        -webkit-background-clip: padding-box;
        background-clip: padding-box;
    }
    
    /* Fix button colors on iOS */
    button,
    .btn-framer,
    .analyze-btn {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* Dark theme specific iOS fixes */
    [data-theme="dark"] {
        color-scheme: dark;
    }
    
    [data-theme="dark"] input,
    [data-theme="dark"] textarea,
    [data-theme="dark"] select {
        color-scheme: dark;
    }
    
    /* Matrix theme iOS fix */
    [data-theme="matrix"] * {
        -webkit-font-smoothing: none;
    }
    
    /* Colorful theme iOS fix */
    [data-theme="colorful"] .nav-framer {
        background-image: linear-gradient(135deg, #EC4899 0%, #8B5CF6 100%) !important;
        -webkit-background-clip: padding-box;
        background-clip: padding-box;
    }
    
    /* Windows XP theme iOS fix */
    [data-theme="windows-xp"] button {
        background-image: linear-gradient(180deg, #FFFFFF 0%, #ECE9D8 5%, #D4D0C8 95%, #B4B0A8 100%) !important;
    }
}

/* iPhone specific media query */
@media screen and (max-width: 414px) and (-webkit-min-device-pixel-ratio: 2) {
    /* Ensure theme colors are visible */
    :root {
        color-scheme: light;
    }
    
    [data-theme="dark"] {
        color-scheme: dark;
    }
    
    /* Fix theme selector dropdown position */
    .theme-dropdown {
        right: -10px;
        min-width: 180px;
    }
    
    /* Fix checkbox size on iPhone */
    input[type="checkbox"] {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
    }
    
    /* Fix job card checkbox alignment */
    .job-card {
        display: flex;
        align-items: center;
    }
    
    .job-card input[type="checkbox"] {
        margin-right: 15px;
    }
}

/* iPhone X and newer specific fixes */
@media screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3),
       screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2),
       screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3),
       screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3),
       screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) {
    
    /* Account for safe area insets */
    .nav-framer {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .hero-section {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

/* Force GPU acceleration for smoother theme transitions on iOS */
.theme-transition * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}

/* Prevent text selection issues on iOS */
.theme-selector-btn,
.theme-option,
input[type="checkbox"] + label {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Fix focus states on iOS */
@media (hover: none) and (pointer: coarse) {
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}