/* CSS Reset & Variables */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --gray-900: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;
    --white: #ffffff;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-3: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    text-align: center;
    padding: 15px 20px;
    background: var(--gradient-2);
    border-radius: var(--radius-lg);
    margin-bottom: 15px;
    color: var(--white);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.tagline {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 15px;
}

/* Upload Section */
.upload-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 25px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area.dragover {
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    width: 40px;
    height: 40px;
    color: var(--primary);
}

.upload-content h2 {
    font-size: 1.1rem;
    color: var(--gray-800);
}

.upload-content p {
    color: var(--gray-500);
    font-size: 0.85rem;
}

.file-types {
    display: inline-block;
    background: var(--primary);
    color: var(--white);
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Options Section */
.options-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 15px;
}

.options-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.compression-modes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 10px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn svg {
    width: 22px;
    height: 22px;
    color: var(--gray-500);
    transition: var(--transition);
}

.mode-btn span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.mode-btn small {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.mode-btn:hover {
    border-color: var(--primary-light);
}

.mode-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.mode-btn.active svg {
    color: var(--primary);
}

.mode-btn.active span {
    color: var(--primary);
}

/* Quality Control */
.quality-control {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.quality-control.hidden {
    display: none;
}

.quality-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.quality-header label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.quality-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--white);
    padding: 3px 10px;
    border-radius: 50px;
}

.quality-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-200);
    border-radius: 20px;
    outline: none;
    cursor: pointer;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--gradient-2);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.quality-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.quality-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--gradient-2);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.quality-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--gray-500);
}

/* Format Control */
.format-control {
    margin-bottom: 15px;
}

.format-control label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.format-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.format-btn {
    padding: 6px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 50px;
    background: var(--white);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.format-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.format-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

/* Compress Button */
.compress-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--gradient-2);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.compress-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    opacity: 0.95;
}

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

.compress-btn svg {
    width: 18px;
    height: 18px;
}

/* Preview Section */
.preview-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 15px;
    grid-column: 1 / -1;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.preview-header h3 {
    font-size: 1rem;
    color: var(--gray-800);
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--white);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

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

.action-btn.secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.action-btn.secondary:hover {
    background: var(--gray-300);
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* Images Grid */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.image-card {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

.image-card:hover {
    transform: translateY(-2px);
}

.image-preview {
    position: relative;
    height: 100px;
    overflow: hidden;
    background: var(--gray-200);
}

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

.image-status {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 3px 8px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.image-status.pending {
    background: var(--warning);
    color: var(--white);
}

.image-status.compressed {
    background: var(--success);
    color: var(--white);
}

.image-status.processing {
    background: var(--secondary);
    color: var(--white);
}

.image-info {
    padding: 10px;
}

.image-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-800);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-sizes {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.size-info {
    text-align: center;
}

.size-label {
    display: block;
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.size-value {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-700);
}

.size-value.original {
    color: var(--warning);
}

.size-value.compressed {
    color: var(--success);
}

.savings-badge {
    text-align: center;
    padding: 4px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}

.savings-badge span {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--success);
}

.image-actions {
    display: flex;
    gap: 6px;
}

.img-action-btn {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.img-action-btn.download {
    background: var(--primary);
    color: var(--white);
}

.img-action-btn.download:hover {
    background: var(--primary-dark);
}

.img-action-btn.download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.img-action-btn.remove {
    background: var(--gray-200);
    color: var(--gray-600);
}

.img-action-btn.remove:hover {
    background: var(--danger);
    color: var(--white);
}

.img-action-btn svg {
    width: 12px;
    height: 12px;
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    grid-column: 1 / -1;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    padding: 12px;
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.highlight {
    background: var(--gradient-2);
    color: var(--white);
}

.stat-card.highlight .stat-label {
    color: rgba(255, 255, 255, 0.85);
}

.stat-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.stat-card.highlight .stat-icon {
    background: rgba(255, 255, 255, 0.2);
}

.stat-card.highlight .stat-icon svg {
    color: var(--white);
}

.stat-icon.original {
    background: rgba(245, 158, 11, 0.1);
}

.stat-icon.original svg {
    color: var(--warning);
}

.stat-icon.compressed {
    background: rgba(16, 185, 129, 0.1);
}

.stat-icon.compressed svg {
    color: var(--success);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-card.highlight .stat-value {
    color: var(--white);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Footer */
.footer {
    text-align: center;
    padding: 15px 10px;
    margin-top: 10px;
}

.footer p {
    color: var(--gray-600);
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.footer-features {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-features span {
    color: var(--gray-500);
    font-size: 0.8rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    color: var(--white);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-content p {
    font-size: 1rem;
    margin-bottom: 15px;
}

.progress-bar {
    width: 250px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    overflow: hidden;
    margin: 0 auto 8px;
}

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

.progress-text {
    font-size: 0.85rem;
    color: var(--gray-300);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px 15px;
    color: var(--gray-500);
    grid-column: 1 / -1;
}

.empty-state svg {
    width: 50px;
    height: 50px;
    color: var(--gray-300);
    margin-bottom: 10px;
}

.empty-state h4 {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 12px 15px;
        border-radius: var(--radius-lg);
    }

    .logo {
        font-size: 1.2rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .tagline {
        font-size: 0.8rem;
    }

    .upload-area {
        padding: 20px 15px;
    }

    .upload-icon {
        width: 32px;
        height: 32px;
    }

    .upload-content h2 {
        font-size: 1rem;
    }

    .compression-modes {
        grid-template-columns: 1fr 1fr;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-actions {
        width: 100%;
    }

    .preview-actions .action-btn {
        flex: 1;
        justify-content: center;
    }

    .images-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 200px;
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-features {
        gap: 10px;
    }

    .progress-bar {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .stats-section {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card {
        padding: 10px;
    }

    .format-options {
        gap: 4px;
    }

    .format-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    
    .images-grid {
        grid-template-columns: 1fr;
    }
}

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

.image-card {
    animation: fadeIn 0.4s ease;
}

/* Comparison Slider Styles */
.comparison-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 15px;
}

.comparison-original,
.comparison-compressed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.comparison-original img,
.comparison-compressed img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comparison-compressed {
    clip-path: inset(0 50% 0 0);
}

.comparison-slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: var(--white);
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
}

.comparison-slider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comparison-label {
    position: absolute;
    bottom: 10px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    font-size: 0.75rem;
    border-radius: 4px;
}

.comparison-label.original-label {
    left: 10px;
}

.comparison-label.compressed-label {
    right: 10px;
}
