/**
 * Ultra-Quality Image Resizer - Main Stylesheet
 * Modern, professional interface with mobile-first responsive design
 */

/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    line-height: 1.6;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2d3748;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
    color: white;
    padding: 2rem 0;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: clamp(1rem, 3vw, 1.25rem);
    margin-bottom: 1.5rem;
    opacity: 0.95;
    font-weight: 300;
}

.quality-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.875rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Main Card */
.main-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.15);
    padding: clamp(1.5rem, 5vw, 3rem);
    margin-bottom: 2rem;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Upload Zone */
.upload-zone {
    border: 3px dashed #e2e8f0;
    border-radius: 16px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
    position: relative;
    overflow: hidden;
}

.upload-zone:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.15);
}

.upload-zone.dragover {
    border-color: #667eea;
    background: #e8f2ff;
    transform: scale(1.02);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.25);
}

.upload-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s;
}

.upload-zone:hover::before {
    left: 100%;
}

.upload-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1.25rem;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.upload-zone h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2d3748;
}

.upload-description {
    color: #64748b;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* File Information Display */
.file-info {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.file-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

.file-preview {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-meta h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2d3748;
    word-break: break-all;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-item label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
}

.meta-item span {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2d3748;
}

/* Options Section */
#options-section {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid #e2e8f0;
}

.options-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.option-group {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.option-group h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2d3748;
}

/* Dimension Inputs */
.dimension-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #4a5568;
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.aspect-lock {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #d1d5db;
    background: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-icon.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.preset-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Quality Modes */
.quality-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quality-option {
    cursor: pointer;
}

.quality-option input[type="radio"] {
    display: none;
}

.quality-card {
    padding: 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.quality-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}

.quality-option input[type="radio"]:checked + .quality-card {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
}

.quality-card h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.quality-card p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.quality-card small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Premium quality mode styling */
.quality-card.premium-mode {
    border: 2px solid #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 15%);
    position: relative;
    overflow: hidden;
}

.quality-card.premium-mode::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #f59e0b, #d97706, #b45309, #f59e0b);
    background-size: 400% 400%;
    border-radius: 12px;
    z-index: -1;
    animation: premium-glow 3s ease-in-out infinite;
}

@keyframes premium-glow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.quality-card.premium-mode:hover {
    border-color: #d97706;
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.25);
}

.quality-option input[type="radio"]:checked + .quality-card.premium-mode {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(245, 158, 11, 0.4);
}

/* Laboratory Grade quality mode styling */
.quality-card.laboratory-mode {
    border: 3px solid #8b5cf6;
    background: linear-gradient(135deg, #f3e8ff 0%, #c084fc 15%, #8b5cf6 30%);
    position: relative;
    overflow: hidden;
}

.quality-card.laboratory-mode::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #8b5cf6, #7c3aed, #6d28d9, #5b21b6, #8b5cf6);
    background-size: 500% 500%;
    border-radius: 15px;
    z-index: -1;
    animation: laboratory-pulse 2s ease-in-out infinite;
}

.quality-card.laboratory-mode::after {
    content: '🧬';
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    animation: laboratory-spin 4s linear infinite;
}

@keyframes laboratory-pulse {
    0%, 100% { 
        background-position: 0% 50%;
        transform: scale(1);
    }
    50% { 
        background-position: 100% 50%;
        transform: scale(1.02);
    }
}

@keyframes laboratory-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.quality-card.laboratory-mode:hover {
    border-color: #7c3aed;
    transform: translateY(-5px);
    box-shadow: 0 20px 50px rgba(139, 92, 246, 0.3);
}

.quality-option input[type="radio"]:checked + .quality-card.laboratory-mode {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
    color: white;
    transform: translateY(-6px);
    box-shadow: 0 25px 60px rgba(139, 92, 246, 0.5);
}

/* Output Format Selector */
.format-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.format-option {
    cursor: pointer;
}

.format-option input[type="radio"] {
    display: none;
}

.format-card {
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.format-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.15);
}

.format-card.active-format,
.format-option input[type="radio"]:checked + .format-card {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.3);
}

.format-card .format-name {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.format-card small {
    font-size: 0.75rem;
    opacity: 0.85;
}

.jpeg-quality-slider {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
}

.jpeg-quality-slider label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: #4a5568;
}

.jpeg-quality-slider input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    outline: none;
}

.jpeg-quality-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

/* Advanced Options */
.advanced-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.checkbox-option:hover {
    background: rgba(102, 126, 234, 0.05);
}

.checkbox-option input[type="checkbox"] {
    margin-top: 0.125rem;
    width: 1rem;
    height: 1rem;
    accent-color: #667eea;
}

.checkbox-option span {
    font-weight: 500;
    color: #2d3748;
}

.checkbox-option small {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    display: block;
}

/* Process Section */
.process-section {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 16px;
    margin-top: 2rem;
}

.process-note {
    margin-top: 1rem;
    color: #64748b;
    font-size: 0.875rem;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    user-select: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.3);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Error Handling */
.webp-error {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(245, 101, 101, 0.3);
}

.webp-error h3 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.webp-error p {
    margin-bottom: 0.5rem;
    opacity: 0.95;
}

/* Message Container */
.message-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    max-width: 400px;
}

.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message.success {
    background: #48bb78;
    color: white;
}

.message.error {
    background: #f56565;
    color: white;
}

.message.warning {
    background: #ed8936;
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 3rem;
    padding: 2rem 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: white;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }
    
    .main-card {
        padding: 1.5rem;
        border-radius: 16px;
    }
    
    .upload-zone {
        padding: 2rem 1rem;
    }
    
    .file-details {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .file-preview {
        justify-self: center;
    }
    
    .dimension-inputs {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .aspect-lock {
        order: -1;
        justify-self: center;
        margin-bottom: 0.5rem;
    }
    
    .quality-modes {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        gap: 0.75rem;
    }
    
    .footer-links {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* High-resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .header h1 {
        text-rendering: optimizeLegibility;
    }
    
    .btn {
        -webkit-font-smoothing: subpixel-antialiased;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .upload-zone::before {
        display: none;
    }
}

/* Focus management for accessibility */
.btn:focus,
.input-group input:focus,
.checkbox-option:focus-within,
.quality-option:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .upload-zone {
        border-width: 4px;
    }
    
    .btn-outline {
        border-width: 3px;
    }
    
    .quality-card {
        border-width: 3px;
    }
}