/* CSS Custom Properties based on color palette */
:root {
    /* Primary Colors */
    --primary-base: #b24e47;
    --primary-light: #d4736b;
    --primary-dark: #8f3e38;
    
    /* Secondary Colors */
    --secondary-base: #7c4dff;
    --secondary-light: #b085f5;
    --secondary-dark: #5e35b1;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #b24e47 0%, #7c4dff 100%);
    --gradient-warm: linear-gradient(45deg, #d4736b, #8f63ff);
    --gradient-subtle: linear-gradient(135deg, rgba(178, 78, 71, 0.08) 0%, rgba(124, 77, 255, 0.12) 100%);
    
    /* Neutrals */
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --medium-gray: #6c757d;
    --dark-gray: #343a40;
    --black: #000000;
    
    /* Semantic Colors */
    --success: #28a745;
    --success-light: #d4edda;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    
    /* Interaction States */
    --hover-glow: rgba(124, 77, 255, 0.4);
    --active-press: #5e35b1;
    --focus-outline: #b085f5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gradient-subtle);
    min-height: 100vh;
    color: var(--dark-gray);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    text-align: center;
    background: var(--gradient-primary);
    color: var(--white);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Drop Zone Styles */
.drop-zone-section {
    margin-bottom: 2rem;
}

.drop-zone {
    border: 3px dashed var(--primary-light);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    background: var(--white);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-subtle);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone.drag-over {
    border-color: var(--secondary-base);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px var(--hover-glow);
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.drop-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.drop-zone h3 {
    color: var(--primary-base);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.drop-zone p {
    color: var(--medium-gray);
    margin-bottom: 1.5rem;
}

.select-btn {
    background: var(--gradient-warm);
    color: var(--white);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(178, 78, 71, 0.3);
}

.select-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(178, 78, 71, 0.4);
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-top: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.file-stats {
    display: flex;
    gap: 2rem;
    font-weight: 600;
    color: var(--primary-base);
}

.clear-btn {
    background: var(--danger);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* File List Styles */
.file-list-section {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.file-list-section h3 {
    color: var(--primary-base);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.file-list {
    display: grid;
    gap: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: 12px;
    border-left: 4px solid var(--primary-light);
    transition: all 0.3s ease;
}

.file-item:hover {
    background: #e9ecef;
    transform: translateX(4px);
}

.file-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--medium-gray);
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 0.25rem;
}

.file-size {
    font-size: 0.9rem;
    color: var(--medium-gray);
}

.remove-file {
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-file:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Settings Styles */
.settings-section {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.settings-section h3 {
    color: var(--primary-base);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    align-items: end;
}

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

.setting-group label {
    font-weight: 600;
    color: var(--dark-gray);
}

.format-select {
    padding: 0.75rem;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.format-select:focus {
    outline: none;
    border-color: var(--secondary-base);
    box-shadow: 0 0 0 3px var(--hover-glow);
}

.quality-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: var(--light-gray);
    outline: none;
    cursor: pointer;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-warm);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.quality-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-warm);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.size-estimate {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--gradient-subtle);
    border-radius: 12px;
    font-weight: 600;
    color: var(--primary-base);
    grid-column: 1 / -1;
}

/* Preview Styles */
.preview-section {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.preview-section h3 {
    color: var(--primary-base);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.image-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-btn {
    background: var(--gradient-warm);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--hover-glow);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.zoom-controls {
    display: flex;
    gap: 0.5rem;
}

.zoom-btn {
    background: var(--light-gray);
    border: 2px solid var(--light-gray);
    color: var(--dark-gray);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.zoom-btn.active {
    background: var(--gradient-warm);
    border-color: var(--primary-base);
    color: var(--white);
}

.zoom-btn:hover {
    background: var(--gradient-warm);
    color: var(--white);
}

.image-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.image-side h4 {
    color: var(--primary-base);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.1rem;
}

.image-wrapper {
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    padding: 1rem;
    background: var(--light-gray);
    text-align: center;
}

.image-wrapper img,
.image-wrapper canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.image-info {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--medium-gray);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.size-change {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

.size-change.positive {
    background: var(--success-light);
    color: var(--success);
}

.size-change.negative {
    background: #f8d7da;
    color: var(--danger);
}

/* Actions Styles */
.actions-section {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.action-buttons {
    margin-bottom: 2rem;
}

.convert-btn {
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    padding: 1rem 3rem;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(124, 77, 255, 0.3);
    margin-bottom: 1rem;
}

.convert-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(124, 77, 255, 0.4);
}

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

.download-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.download-btn {
    background: var(--gradient-warm);
    color: var(--white);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(178, 78, 71, 0.3);
}

.download-btn.secondary {
    background: var(--light-gray);
    color: var(--dark-gray);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(178, 78, 71, 0.4);
}

.download-btn.secondary:hover {
    background: var(--medium-gray);
    color: var(--white);
}

.progress-container {
    margin-top: 2rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--light-gray);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--primary-base);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-title {
        font-size: 2rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .image-comparison {
        grid-template-columns: 1fr;
    }
    
    .preview-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .zoom-controls {
        justify-content: center;
    }
    
    .download-options {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .drop-zone {
        padding: 2rem 1rem;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
    
    .file-info {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .file-stats {
        justify-content: center;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
select:focus,
input:focus {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-base: #000000;
        --secondary-base: #0000ff;
        --white: #ffffff;
        --light-gray: #f0f0f0;
        --dark-gray: #000000;
    }
}
