/* Mobile Optimizations for White Background Remover */
/* Enhanced Mobile-First Responsive Design */

/* Hide mobile menu toggle by default */
.mobile-menu-toggle {
    display: none;
}

/* ===== Skip Navigation Link (Accessibility) ===== */
/* This should work on all devices, not just mobile */
.skip-nav {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100000;
    border-radius: 0 0 8px 0;
    transition: top 0.2s ease;
}

.skip-nav:focus {
    top: 0;
}

/* ===== Mobile Navigation with Hamburger Menu ===== */
@media (max-width: 768px) {
    /* Hamburger Menu Button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        right: 20px;
        z-index: 10001;
        width: 40px;
        height: 40px;
        padding: 0;
        background: var(--primary);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        background: white;
        margin: 5px auto;
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    /* Mobile Navigation Overlay */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 60px;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .navbar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(100vh - 60px);
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 30px 20px;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        overflow-y: auto;
        z-index: 10000;
        box-sizing: border-box;
    }

    .navbar-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .navbar-link {
        display: block;
        padding: 15px 20px;
        font-size: 18px;
        text-align: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        transition: background 0.2s ease;
    }

    .navbar-link:hover, .navbar-link:active {
        background: rgba(37, 99, 235, 0.1);
    }

    .navbar-cta {
        margin-top: 20px;
        width: 90%;
        max-width: 300px;
        align-self: center;
    }
    
    /* Optimize navbar-container for mobile */
    .navbar-container {
        max-width: 100%;
        padding: 0 15px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* ===== Enhanced Touch Targets ===== */
@media (max-width: 768px) {
    /* Larger button touch targets */
    .btn, .btn-primary, .btn-secondary, .btn-sm {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 16px;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        touch-action: manipulation;
    }

    /* Larger clickable areas for language selector */
    .language-button {
        min-height: 44px;
        padding: 10px 16px;
    }

    .language-item {
        padding: 12px 16px;
        min-height: 44px;
    }
}

/* ===== Upload Section Mobile Optimization ===== */
@media (max-width: 768px) {
    .upload-section {
        padding: 60px 15px 40px;
    }

    .drop-zone {
        min-height: 350px;
        padding: 30px 20px;
        margin: 0;
    }

    .drop-zone svg {
        width: 60px;
        height: 60px;
        margin-bottom: 20px;
    }

    .drop-zone h3 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .drop-zone p {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 25px;
    }

    .drop-zone .btn {
        width: 100%;
        max-width: 280px;
        font-size: 16px;
        padding: 14px 24px;
    }

    /* Better file input handling */
    input[type="file"] {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ===== Header/Hero Section Mobile ===== */
@media (max-width: 768px) {
    .header {
        padding: 80px 20px 40px;
        min-height: auto;
    }

    .header h1 {
        font-size: 28px;
        line-height: 1.3;
        margin-bottom: 15px;
    }

    .header p {
        font-size: 16px;
        line-height: 1.6;
        margin-bottom: 25px;
    }

    .hero-cta {
        flex-direction: column;
        gap: 12px;
    }

    .hero-cta .btn {
        width: 100%;
        max-width: 300px;
    }

    .hero-image img {
        max-width: 100%;
        height: auto;
    }
}

/* ===== Image Comparison Mobile Optimization ===== */
@media (max-width: 768px) {
    .comparison-container {
        max-width: 100%;
        min-height: 280px;
        border-radius: 12px;
        margin: 20px 0;
    }

    /* Larger slider button for touch */
    .slider-button {
        width: 44px;
        height: 44px;
        border: 3px solid white;
    }

    .slider-button svg {
        width: 24px;
        height: 24px;
    }

    /* Better touch feedback */
    .slider-button:active {
        transform: scale(1.1);
        background: rgba(255, 255, 255, 0.98);
    }

    /* Optimize labels */
    .comparison-label {
        font-size: 11px;
        padding: 6px 10px;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .comparison-label-left {
        left: 8px;
        top: 8px;
    }

    .comparison-label-right {
        right: 8px;
        top: 8px;
    }

    /* Touch-optimized dragging */
    .comparison-container {
        touch-action: pan-y pinch-zoom;
    }

    .slider-handle {
        touch-action: none;
    }
}

/* ===== Quick Actions Grid Mobile ===== */
@media (max-width: 768px) {
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 20px 15px;
    }

    .quick-action {
        padding: 15px;
        min-height: 120px;
    }

    .quick-action svg {
        width: 32px;
        height: 32px;
        margin-bottom: 10px;
    }

    .quick-action span {
        font-size: 13px;
        line-height: 1.4;
    }

    .quick-action:active {
        transform: scale(0.98);
        background: rgba(37, 99, 235, 0.15);
    }
}

@media (max-width: 480px) {
    .quick-actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .quick-action {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 16px;
        min-height: auto;
        text-align: left;
    }

    .quick-action svg {
        margin-right: 12px;
        margin-bottom: 0;
    }
}

/* ===== Result Section Mobile ===== */
@media (max-width: 768px) {
    .result-section {
        padding: 20px 15px;
    }

    .result-content {
        padding: 20px 15px;
        border-radius: 16px;
    }

    .result-header {
        padding-bottom: 20px;
    }

    .result-header h3 {
        font-size: 22px;
        text-align: center;
    }

    .result-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }

    .result-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Better mobile stats display */
    .result-stats {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 20px 0;
    }

    .stat-item {
        padding: 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* ===== Footer Mobile Optimization ===== */
@media (max-width: 768px) {
    .site-footer {
        margin-top: 60px;
        padding: 40px 0 20px;
    }

    .footer-container {
        padding: 0 15px;
    }

    .footer-content {
        padding: 0 0 30px;
    }

    .footer-main {
        flex-direction: column;
        gap: 40px;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h4 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .footer-links {
        align-items: center;
    }

    .footer-link {
        padding: 8px 0;
        font-size: 14px;
    }

    .footer-badges {
        flex-direction: column;
        gap: 12px;
    }

    .footer-badge {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 15px;
        padding: 20px 0;
        text-align: center;
    }

    .footer-tech {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .footer-tech .separator {
        display: none;
    }
}

/* ===== Touch and Gesture Optimization ===== */
@media (pointer: coarse) {
    /* Optimize for touch devices */
    .drop-zone {
        cursor: default;
    }

    .drop-zone.drag-over {
        border-width: 3px;
        background: rgba(37, 99, 235, 0.08);
    }

    /* Disable hover effects on touch devices */
    .btn:hover, .quick-action:hover {
        transform: none;
    }

    /* Add active states for better feedback */
    .btn:active {
        transform: scale(0.98);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    /* Optimize scrolling */
    .navbar-menu, .language-dropdown {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* ===== Small Phone Optimization (< 380px) ===== */
@media (max-width: 380px) {
    .header h1 {
        font-size: 24px;
    }

    .header p {
        font-size: 14px;
    }

    .drop-zone {
        min-height: 300px;
        padding: 25px 15px;
    }

    .drop-zone h3 {
        font-size: 18px;
    }

    .btn {
        font-size: 14px;
        padding: 10px 20px;
    }

    .comparison-container {
        min-height: 240px;
    }

    .quick-actions {
        padding: 15px 10px;
    }

    .result-header h3 {
        font-size: 20px;
    }
}

/* ===== Performance Optimizations ===== */
@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Disable complex animations */
    .fade-in-up, .scale-in {
        animation: none;
        opacity: 1;
        transform: none;
    }

    /* Optimize backdrop filters for performance */
    @supports not (backdrop-filter: blur(10px)) {
        .navbar, .navbar-menu, .comparison-label {
            background: rgba(255, 255, 255, 0.95);
        }
    }
}

/* ===== Accessibility Improvements ===== */
@media (max-width: 768px) {
    /* Better focus indicators */
    .btn:focus, .navbar-link:focus, .language-button:focus {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }
}

/* ===== Landscape Mode Adjustments ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        min-height: auto;
        padding: 60px 20px 30px;
    }

    .drop-zone {
        min-height: 250px;
    }

    .comparison-container {
        max-height: 60vh;
    }

    .navbar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 20px;
    }

    .navbar-link {
        flex: 0 0 48%;
        margin: 1%;
    }
}

/* ===== iOS Specific Fixes ===== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari fixes */
    .navbar {
        -webkit-transform: translate3d(0, 0, 0);
    }

    input[type="file"] {
        font-size: 16px;
    }

    .btn, button {
        -webkit-appearance: none;
    }

    /* Fix for iOS bounce scrolling - using safer approach */
    /* Only apply on mobile screens to avoid breaking desktop layouts */
    @media (max-width: 768px) {
        body {
            -webkit-overflow-scrolling: touch;
        }
        
        /* Alternative approach without fixed positioning */
        html {
            height: 100%;
            overflow-x: hidden;
        }
    }
}

/* ===== Android Specific Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Optimize for Android devices */
    .btn {
        transition: transform 0.1s ease;
    }

    .btn:active {
        transform: scale(0.96);
    }

    /* Better scrolling on Android */
    * {
        scroll-behavior: smooth;
    }
}