/* ===== CSS Variables ===== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #22c55e;
    --success-hover: #16a34a;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===== Upload Section ===== */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    background: var(--card-bg);
    border: 2px dashed var(--card-border);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

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

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-btn {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.upload-btn:hover {
    background: var(--primary-hover);
}

.upload-hint {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===== Controls Section ===== */
.controls-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: none;
}

.controls-section.visible {
    display: block;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group:last-of-type {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.control-group select,
.control-group input[type="number"] {
    background: var(--bg-color);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    max-width: 300px;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Quality Slider */
.control-group input[type="range"] {
    width: 100%;
    max-width: 400px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-color);
    border-radius: 4px;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

.quality-labels {
    display: flex;
    justify-content: space-between;
    max-width: 400px;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Resize Options */
.resize-options {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.resize-options.visible {
    display: flex;
}

.resize-options input[type="number"] {
    width: 120px;
}

.resize-options span {
    color: var(--text-muted);
}

.resize-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
    cursor: pointer;
}

/* ===== Buttons ===== */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-danger {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-color);
    color: white;
}

.btn-icon {
    font-size: 1.1rem;
}

/* ===== Progress Section ===== */
.progress-section {
    display: none;
    margin-bottom: 2rem;
}

.progress-section.visible {
    display: block;
}

.progress-bar {
    height: 8px;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #a855f7);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== Stats Section ===== */
.stats-section {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stats-section.visible {
    display: grid;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
}

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

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Images Section ===== */
.images-section {
    display: none;
}

.images-section.visible {
    display: block;
}

.images-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Image Card */
.image-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.image-preview {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-color);
}

.image-info {
    padding: 1rem;
}

.image-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.image-size {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.size-original {
    color: var(--text-muted);
}

.size-converted {
    color: var(--success-color);
    font-weight: 600;
}

.size-converted.larger {
    color: var(--danger-color);
}

.image-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.status-icon {
    font-size: 1rem;
}

.status-pending {
    color: var(--text-muted);
}

.status-processing {
    color: var(--primary-color);
}

.status-done {
    color: var(--success-color);
}

.status-error {
    color: var(--danger-color);
}

.image-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.image-remove:hover {
    background: var(--danger-color);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--card-border);
}

footer p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .images-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Animations ===== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spinning {
    animation: spin 1s linear infinite;
}

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

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