/* Corrected Mobile Responsiveness Fixes */

/* File Upload Button Fixes - Only Button Clickable */
@media (max-width: 768px) {
    /* Ensure file input buttons work properly on mobile */
    button[onclick*="fileInput"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
        cursor: pointer;
    }
    
    /* Make sure upload areas don't interfere with button clicks */
    .upload-area {
        position: relative;
    }
    
    .upload-area input[type="file"] {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
        pointer-events: none;
    }
    
    /* Keep buttons fully interactive */
    .upload-area button,
    .upload-area .btn,
    .upload-area .upload-button {
        pointer-events: auto;
        position: relative;
        z-index: 2;
        cursor: pointer;
    }
}

/* General Overflow Fixes */
@media (max-width: 768px) {
    /* Prevent horizontal overflow */
    body {
        overflow-x: hidden;
    }
    
    /* Fix container widths without affecting header */
    .container:not(.nav-container),
    .page-container {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        box-sizing: border-box;
    }
    
    /* Keep nav-container unchanged to preserve header alignment */
    .nav-container {
        /* Don't modify nav-container to maintain header alignment */
    }
    
    /* Fix wide elements */
    img:not(.logo img),
    video,
    canvas {
        max-width: 100%;
        height: auto;
    }
    
    /* Fix tables on mobile */
    table {
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }
    
    /* Fix pre and code elements */
    pre,
    code {
        overflow-x: auto;
        word-break: break-word;
    }
}

/* Form Input Improvements (without select fixes) */
@media (max-width: 768px) {
    /* Prevent zoom on iOS inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 12px 16px;
        border-radius: 8px;
        border: 2px solid #e2e8f0;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus,
    input[type="number"]:focus,
    textarea:focus {
        border-color: #667eea;
        outline: none;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }
    
    /* Keep select elements unchanged to avoid first-click issues */
    select {
        font-size: 16px; /* Only prevent zoom, don't change styling */
        min-height: 44px;
    }
}

/* Touch Target Improvements */
@media (max-width: 768px) {
    /* Ensure all interactive elements meet minimum touch target size */
    button,
    .btn,
    a[role="button"],
    input[type="button"],
    input[type="submit"],
    input[type="reset"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Navigation improvements without affecting header alignment */
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }
}

/* Grid and Layout Fixes */
@media (max-width: 768px) {
    /* Fix grid layouts */
    .features-grid,
    .tools-container,
    .main-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Fix flexbox layouts */
    .hero-buttons,
    .button-group {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Fix spacing */
    .hero-section,
    .features,
    .info-section {
        padding: 2rem 1rem;
    }
    
    /* Fix typography scaling */
    .hero-title {
        font-size: clamp(1.8rem, 5vw, 2.5rem);
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 3vw, 1.2rem);
    }
}

/* Canvas and Media Mobile Fixes */
@media (max-width: 768px) {
    canvas {
        max-width: 100%;
        height: auto;
        touch-action: pan-x pan-y;
    }
    
    .canvas-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix video containers */
    .video-container,
    .video-ad-container {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
}

/* Accessibility Improvements for Mobile */
@media (max-width: 768px) {
    /* Improve focus indicators */
    *:focus {
        outline: 2px solid #667eea;
        outline-offset: 2px;
    }
    
    /* Improve text contrast and sizing */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
}

/* Header-specific fixes to prevent alignment issues */
@media (max-width: 968px) {
    /* Ensure mobile menu behavior doesn't affect header alignment */
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 400px;
        height: 100vh;
        background: var(--white);
        flex-direction: column;
        padding: 5rem 2rem;
        gap: 1rem;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
        transition: var(--transition);
        overflow-y: auto;
    }
    
    .nav-links.active {
        right: 0;
    }
    
    .mobile-menu-btn {
        display: block;
        z-index: 1001;
    }
    
    /* Preserve dropdown styling in mobile menu */
    .dropdown-content {
        position: relative;
        display: block !important;
        min-width: 100%;
        box-shadow: none;
        border-radius: 10px;
        padding: 1rem;
        top: 0;
        left: 0;
        transform: none;
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
        background: #f8f9fa;
        border: 1px solid #e0e0e0;
    }
}

/* Additional responsive breakpoints */
@media (max-width: 640px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}