/* Enhanced mobile optimizations */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .card {
        padding: 1.5rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-xl);
    }
    
    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn {
        padding: 1.25rem 1.5rem;
        font-size: 1.1rem;
        min-height: 56px;
    }
    
    .preset-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 0.75rem;
    }
    
    .preset-btn {
        padding: 1rem 0.75rem;
        font-size: 0.9rem;
        min-height: 48px;
    }
    
    .resolution-inputs {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .radio-item {
        padding: 1rem 1.25rem;
        min-height: 56px;
    }
    
    .file-input-button {
        padding: 1.5rem;
        font-size: 1.1rem;
        min-height: 64px;
    }
    
    .file-item {
        padding: 1.25rem;
    }
    
    .file-preview {
        width: 56px;
        height: 56px;
    }
    
    .preview-image {
        max-height: 300px;
    }
    
    .slider {
        height: 10px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    .slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
}

/* Enhanced touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 56px;
        font-size: 1.1rem;
    }
    
    .preset-btn {
        min-height: 48px;
        font-size: 0.9rem;
    }
    
    .form-input {
        min-height: 56px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem 1.25rem;
    }
    
    .slider {
        height: 10px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    .slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
    
    .file-input-button {
        min-height: 64px;
        font-size: 1.1rem;
    }
    
    .radio-item {
        min-height: 56px;
        padding: 1rem 1.25rem;
    }
}

/* Enhanced performance optimizations */
.card {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.preview-image {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.btn {
    will-change: transform;
    backface-visibility: hidden;
}

/* Enhanced accessibility improvements */
.btn:focus,
.preset-btn:focus,
.form-input:focus,
.slider:focus,
.radio-item:focus-within {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-md);
}

/* Enhanced dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
        --surface: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border: #334155;
        --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3);
    }
    
    .preview-placeholder {
        background: linear-gradient(135deg, #1e293b, #334155);
        border-color: #475569;
    }
    
    .preview-placeholder:hover {
        background: linear-gradient(135deg, #334155, #475569);
        border-color: var(--primary);
    }
}

/* Enhanced loading animation improvements */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

.loading .spinner {
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite;
}

.loading div {
    animation: bounce 2s infinite;
}

/* Enhanced file upload drag and drop */
.file-input-wrapper {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.file-input-wrapper.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
}

/* Enhanced success/error animations */
.alert {
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced responsive typography */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .header p {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .card-title {
        font-size: 1.2rem;
        line-height: 1.3;
    }
    
    .card-subtitle {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .form-label {
        font-size: 0.95rem;
    }
    
    .info-text {
        font-size: 0.85rem;
    }
}

/* Enhanced hover effects */
.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl), 0 25px 50px -12px rgba(0,0,0,0.25);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.file-input-wrapper:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Enhanced focus states */
.btn:focus,
.preset-btn:focus,
.form-input:focus,
.slider:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Enhanced transitions */
* {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced print styles */
@media print {
    .btn,
    .file-input-wrapper,
    .loading,
    .slider,
    .preset-btn {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 2px solid #000;
        break-inside: avoid;
    }
    
    .preview-image {
        max-height: 400px;
        page-break-inside: avoid;
    }
}

/* Enhanced scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Enhanced selection styling */
::selection {
    background: var(--primary);
    color: white;
}

/* Enhanced focus visible for keyboard navigation */
.btn:focus-visible,
.preset-btn:focus-visible,
.form-input:focus-visible,
.slider:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Enhanced reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading .spinner {
        animation: spin 2s linear infinite;
    }
}

/* Enhanced high contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #0000ff;
        --primary-dark: #000080;
        --text-primary: #000000;
        --text-secondary: #333333;
        --border: #000000;
    }
    
    .card {
        border: 2px solid var(--border);
    }
    
    .btn {
        border: 2px solid var(--border);
    }
    
    /* Enhanced select dropdown contrast for high contrast mode */
    .form-input {
        border: 2px solid var(--border);
        background: #ffffff;
        color: #000000;
    }
    
    .form-input option {
        background: #ffffff;
        color: #000000;
        border: 1px solid var(--border);
    }
    
    .form-input option:hover {
        background: var(--primary);
        color: #ffffff;
    }
}

/* Additional select dropdown improvements for better accessibility */
select.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Ensure dropdown options are visible in all browsers */
.form-input option {
    font-weight: 500;
    min-height: 1.5em;
    background: #ffffff !important;
    color: #1e293b !important;
}

/* Force white background for dropdown list */
select.form-input {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

/* Ensure dropdown list has proper contrast */
select.form-input:focus {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

/* Firefox specific select styling */
@-moz-document url-prefix() {
    select.form-input {
        background-image: none;
        padding-right: 1.25rem;
    }
    
    select.form-input::-moz-focus-inner {
        border: 0;
    }
} 