/* Responsive styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
        background: var(--bg-primary);
    }
    
    .container {
        border-radius: 16px;
        border: 1px solid var(--border-color);
    }
    
    header {
        padding: 35px 25px;
    }
    
    header h1 {
        font-size: 2em;
        margin-bottom: 8px;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .tabs {
        flex-direction: column;
        border-bottom: none;
    }
    
    .tab-btn {
        padding: 16px 20px;
        border-bottom: 2px solid var(--border-color);
        border-right: none;
        text-align: left;
    }
    
    .tab-btn::after {
        display: none;
    }
    
    .tab-btn.active {
        border-left: 4px solid var(--primary-color);
        border-bottom-color: var(--border-color);
        background: var(--bg-secondary);
    }
    
    .tab-content {
        padding: 25px 20px;
    }
    
    .form-section h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }
    
    .input-group {
        margin-bottom: 20px;
    }
    
    .input-group input,
    .input-group textarea {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn-large {
        padding: 14px 24px;
        font-size: 16px;
        min-height: 52px;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .gallery-header h3 {
        font-size: 1.3em;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .gallery-item img {
        height: 150px;
    }
    
    .gallery-item-actions {
        opacity: 1; /* Always visible on mobile */
        top: 8px;
        right: 8px;
    }
    
    .btn-gallery-select,
    .btn-gallery-delete,
    .btn-gallery-download {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .result-section {
        padding: 15px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
    }
    
    .result-section img {
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
    }
    
    .result-section > div {
        flex-direction: column;
        gap: 8px;
    }
    
    .result-section .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Better contrast for mobile */
    .gallery-item {
        border: 1px solid var(--border-light);
    }
    
    .input-group input,
    .input-group textarea {
        background: var(--bg-tertiary);
        border-color: var(--border-light);
    }
    
    .input-group input:focus,
    .input-group textarea:focus {
        background: var(--bg-secondary);
        border-color: var(--primary-color);
    }
    
    .modal-content {
        max-width: 95%;
        padding: 15px;
        margin: 20px;
    }
    
    .modal-content img {
        max-height: 60vh;
    }
    
    .modal-close {
        top: 5px;
        right: 15px;
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    header {
        padding: 30px 20px;
    }
    
    header h1 {
        font-size: 1.75em;
    }
    
    .subtitle {
        font-size: 0.95em;
    }
    
    .tab-content {
        padding: 20px 15px;
    }
    
    .form-section h2 {
        font-size: 1.4em;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .gallery-item img {
        height: 120px;
    }
    
    .gallery-item-info {
        padding: 12px;
    }
    
    .gallery-prompt {
        font-size: 13px;
    }
    
    .file-upload-section {
        flex-wrap: wrap;
    }
    
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px; /* Larger touch target for mobile */
        font-size: 16px;
    }
    
    .btn-gallery-select,
    .btn-gallery-delete,
    .btn-gallery-download {
        min-width: 44px;
        min-height: 44px;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(10px);
    }
    
    .gallery-item-actions {
        opacity: 1;
    }
    
    /* Better visibility on mobile */
    .gallery-item {
        box-shadow: var(--shadow-lg);
    }
    
    .tab-btn {
        min-height: 52px;
        padding: 16px 20px;
    }
    
    /* Improve text readability */
    .gallery-prompt {
        color: var(--text-primary);
        font-weight: 500;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 25px 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Dark mode optimizations for OLED screens */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #0a0a0a;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

