/* Mobile-First Responsive Design for ClearBG */

/* Base mobile styles */
@media (max-width: 768px) {
    /* Improved touch targets */
    .nav a,
    .upload-btn,
    .process-btn,
    .hero-btn,
    .cta-btn,
    .download-btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    /* Better spacing for mobile */
    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }

    /* Optimized header for mobile */
    .header {
        padding: 15px;
        position: relative;
    }

    .nav {
        position: static;
        margin-bottom: 20px;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav a {
        font-size: 0.8rem;
        padding: 8px 12px;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
    }

    /* Mobile-optimized upload area */
    .upload-section {
        margin: 20px 0;
        padding: 20px;
        border-radius: 15px;
    }

    .upload-area {
        padding: 40px 20px;
        border-radius: 15px;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    }

    .upload-icon {
        font-size: 3.5rem;
        margin-bottom: 20px;
    }

    .upload-text {
        font-size: 1.1rem;
        margin-bottom: 25px;
        line-height: 1.4;
    }

    /* Mobile preview layout */
    .preview-images {
        grid-template-columns: 1fr;
        gap: 25px;
        margin-bottom: 25px;
    }

    .preview-item {
        background: white;
        padding: 20px;
        border-radius: 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    }

    .preview-image {
        max-height: 300px;
        width: 100%;
        object-fit: contain;
        border-radius: 10px;
    }

    /* Mobile controls */
    .controls {
        flex-direction: column;
        gap: 20px;
        margin-bottom: 25px;
    }

    .control-group {
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }

    .control-group label {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }

    .control-group select {
        width: 100%;
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 10px;
        border: 2px solid #dee2e6;
        background: white;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px;
    }

    /* Mobile process button */
    .process-btn {
        width: 100%;
        max-width: 300px;
        margin: 20px auto;
        padding: 15px 30px;
        font-size: 1.1rem;
        font-weight: 600;
        border-radius: 25px;
        background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
    }

    /* Mobile results */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .result-item {
        background: white;
        padding: 20px;
        border-radius: 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    }

    .result-image {
        max-height: 250px;
        width: 100%;
        object-fit: contain;
        border-radius: 10px;
        margin-bottom: 15px;
    }

    .download-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 20px;
    }

    /* Mobile hero section */
    .hero-section {
        padding: 30px 20px;
        margin-bottom: 30px;
        text-align: center;
    }

    .hero-section h2 {
        font-size: 1.8rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }

    .hero-section p {
        font-size: 1rem;
        margin-bottom: 30px;
        opacity: 0.8;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .hero-btn {
        width: 100%;
        max-width: 280px;
        padding: 15px 25px;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 25px;
    }

    /* Mobile features */
    .features-section {
        margin: 40px 0;
    }

    .features-section h2 {
        font-size: 2rem;
        text-align: center;
        margin-bottom: 30px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .feature-card {
        padding: 25px;
        text-align: center;
        background: white;
        border-radius: 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    }

    .feature-icon {
        font-size: 3rem;
        margin-bottom: 20px;
    }

    .feature-card h3 {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }

    .feature-card p {
        font-size: 1rem;
        line-height: 1.5;
        color: #666;
    }

    /* Mobile how it works */
    .how-it-works-section {
        padding: 40px 20px;
        margin: 40px 0;
        background: #f8f9fa;
        border-radius: 15px;
    }

    .how-it-works-section h2 {
        font-size: 2rem;
        text-align: center;
        margin-bottom: 15px;
    }

    .how-it-works-section p {
        font-size: 1.1rem;
        text-align: center;
        margin-bottom: 40px;
        color: #666;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .step-card {
        background: white;
        padding: 30px 25px;
        border-radius: 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        position: relative;
        text-align: center;
    }

    .step-number {
        position: absolute;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 40px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        font-weight: 700;
    }

    .step-card h3 {
        font-size: 1.4rem;
        margin-bottom: 15px;
        margin-top: 10px;
    }

    .step-card p {
        font-size: 1rem;
        line-height: 1.5;
        color: #666;
    }

    /* Mobile CTA */
    .cta-section {
        padding: 40px 20px;
        margin: 40px 0;
        text-align: center;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 15px;
    }

    .cta-section h2 {
        font-size: 2rem;
        margin-bottom: 15px;
    }

    .cta-section p {
        font-size: 1.1rem;
        margin-bottom: 30px;
        opacity: 0.9;
    }

    .cta-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
        font-weight: 600;
        border-radius: 25px;
        background: white;
        color: #667eea;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

    /* Mobile guide section */
    .guide-section {
        padding: 40px 20px;
        margin: 40px 0;
        background: #f8f9fa;
        border-radius: 15px;
    }

    .guide-section h2 {
        font-size: 2rem;
        text-align: center;
        margin-bottom: 15px;
    }

    .guide-subtitle {
        font-size: 1.1rem;
        text-align: center;
        margin-bottom: 40px;
        color: #666;
        font-style: italic;
    }

    .guide-content {
        max-width: 100%;
    }

    .guide-content h3 {
        font-size: 1.5rem;
        margin-top: 35px;
        margin-bottom: 20px;
        color: #333;
        border-bottom: 2px solid #667eea;
        padding-bottom: 10px;
    }

    .guide-content h4 {
        font-size: 1.2rem;
        margin-top: 25px;
        margin-bottom: 15px;
        color: #444;
    }

    .guide-content p {
        font-size: 1rem;
        margin-bottom: 20px;
        line-height: 1.6;
        color: #555;
    }

    .guide-content ul, .guide-content ol {
        margin-bottom: 25px;
        padding-left: 30px;
    }

    .guide-content li {
        font-size: 0.95rem;
        margin-bottom: 10px;
        line-height: 1.5;
        color: #555;
    }

    /* Mobile footer */
    .footer {
        padding: 40px 0 20px 0;
        margin-top: 50px;
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }

    .footer-content {
        padding: 0 20px;
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h3 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    .footer-section h4 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    .footer-section p {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 15px;
    }

    .footer-section ul {
        list-style: none;
        padding: 0;
    }

    .footer-section ul li {
        margin-bottom: 10px;
    }

    .footer-section ul li a {
        font-size: 0.95rem;
        color: #bdc3c7;
        text-decoration: none;
        transition: color 0.3s ease;
    }

    .footer-section ul li a:hover {
        color: #3498db;
    }

    .footer-bottom {
        border-top: 1px solid #34495e;
        margin-top: 30px;
        padding-top: 20px;
        text-align: center;
    }

    .footer-bottom p {
        font-size: 0.9rem;
        color: #95a5a6;
        margin: 0;
    }

    /* Mobile loading and messages */
    .loading {
        margin: 20px 0;
        text-align: center;
    }

    .spinner {
        width: 40px;
        height: 40px;
        margin: 0 auto 20px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #667eea;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    .error-message, .success-message {
        padding: 15px;
        margin: 20px 0;
        border-radius: 10px;
        font-size: 0.95rem;
        text-align: center;
    }

    .error-message {
        background: #f8d7da;
        color: #721c24;
        border: 1px solid #f5c6cb;
    }

    .success-message {
        background: #d4edda;
        color: #155724;
        border: 1px solid #c3e6cb;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .container {
        margin: 0;
        border-radius: 0;
    }

    .header {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 15px;
    }

    .upload-section {
        padding: 15px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .upload-text {
        font-size: 1rem;
    }

    .hero-section h2 {
        font-size: 1.6rem;
    }

    .features-section h2,
    .how-it-works-section h2,
    .cta-section h2,
    .guide-section h2 {
        font-size: 1.8rem;
    }

    .feature-card,
    .step-card {
        padding: 20px;
    }

    .guide-section {
        padding: 30px 15px;
    }

    .footer {
        padding: 30px 0 15px 0;
    }

    .footer-content {
        padding: 0 15px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav a:hover,
    .upload-btn:hover,
    .process-btn:hover,
    .hero-btn:hover,
    .cta-btn:hover,
    .download-btn:hover {
        transform: none;
        opacity: 0.8;
    }

    .feature-card:hover,
    .step-card:hover,
    .result-item:hover {
        transform: none;
    }

    /* Ensure touch targets are large enough */
    .nav a,
    .upload-btn,
    .process-btn,
    .hero-btn,
    .cta-btn,
    .download-btn,
    .control-group select {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 10px 15px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 15px;
    }

    .upload-area {
        padding: 20px;
    }

    .preview-images {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .preview-image {
        max-height: 200px;
    }
}
