:root {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --bg-quaternary: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-tertiary: #888888;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #818cf8;
    --success: #10b981;
    --success-hover: #059669;
    --error: #ef4444;
    --error-hover: #dc2626;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    line-height: 1.6;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(79, 70, 229, 0.1) 0%, transparent 25%);
}

/* Improved focus styles for accessibility */
button:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 800px;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin: 0 auto;
    font-weight: 400;
    line-height: 1.5;
}

/* Container styles */
.container {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 900px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Upload area improvements */
.upload-area {
    border: 2px dashed #4b5563;
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2.5rem;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.upload-area:hover, 
.upload-area.dragover {
    border-color: var(--accent);
    background-color: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}

.upload-area.dragover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--border-radius-sm);
    z-index: 1;
}

.upload-icon {
    font-size: 3.5rem;
    margin-bottom: 1.25rem;
    color: var(--accent);
    filter: drop-shadow(0 4px 6px rgba(99, 102, 241, 0.3));
    position: relative;
    z-index: 2;
}

.upload-text {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 2;
}

.upload-text small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.file-input {
    display: none;
}

/* Button styles */
.btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 2;
}

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

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.btn i {
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.btn-text:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Controls section */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.format-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.format-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Quality control slider */
.quality-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quality-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#qualitySlider {
    -webkit-appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

#qualitySlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: var(--transition-fast);
}

#qualitySlider::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

#qualitySlider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

#qualitySlider::-moz-range-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* Select styles */
select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid #4b5563;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 3rem;
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Preview section */
.preview-section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.4rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    font-weight: 600;
    gap: 0.75rem;
}

.count-badge {
    background: var(--accent);
    color: white;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.section-title i {
    color: var(--accent);
    font-size: 1.5rem;
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1.25rem;
}

.preview-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.preview-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.preview-img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
}

.preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    padding: 0.75rem;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(5px);
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: var(--transition);
}

.remove-btn:hover {
    background: var(--error-hover);
    transform: scale(1.1);
}

/* Results section */
.results {
    display: none;
    margin-top: 2.5rem;
}

.download-item {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

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

.download-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0; /* Allows text truncation */
}

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

.download-size {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.download-btn {
    background: linear-gradient(135deg, var(--success), var(--success-hover));
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
    white-space: nowrap;
}

.download-btn:hover {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

/* Loading section */
.loading {
    display: none;
    text-align: center;
    margin: 2.5rem 0;
    flex-direction: column;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

/* Progress bar */
.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Footer */
footer {
    margin-top: 3.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 600px;
}

/* Notification */
.notification {
    position: fixed;
    top: 25px;
    right: 25px;
    padding: 1rem 1.5rem;
    background-color: var(--success);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    font-weight: 500;
    max-width: 350px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notification::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background-size: contain;
    flex-shrink: 0;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.error {
    background-color: var(--error);
}

.notification.error::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
}

.notification.show::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
}

/* Download all button */
.download-all-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.download-all-btn {
    background: linear-gradient(135deg, var(--warning), var(--warning-hover));
    box-shadow: 0 4px 6px rgba(245, 158, 11, 0.3);
}

.download-all-btn:hover {
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.4);
}

/* Empty state for preview */
.preview-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-tertiary);
}

.preview-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--text-tertiary);
}

/* Keyboard shortcut hints */
.keyboard-hint {
    display: inline-block;
    background: var(--bg-quaternary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}