/* ===========================================
   ImageCrusher - Professional Web Image Optimizer
   CSS Stylesheet
   =========================================== */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border-color: #30363d;
    --border-light: #484f58;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-primary: #58a6ff;
    --accent-success: #3fb950;
    --accent-warning: #d29922;
    --accent-danger: #f85149;
    --accent-gradient: linear-gradient(135deg, #58a6ff 0%, #a371f7 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Base */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: var(--bg-secondary) !important;
    padding: 12px 20px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.brand-text {
    font-size: 24px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Upload Zone */
.upload-zone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(88, 166, 255, 0.05);
}

.upload-zone.drag-over {
    transform: scale(1.01);
    box-shadow: 0 0 30px rgba(88, 166, 255, 0.2);
}

.upload-icon-wrapper {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.upload-content h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.supported-formats {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* File Queue */
.file-queue {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.file-list {
    max-height: 400px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-item.active {
    border: 2px solid var(--accent-primary);
}

.file-item.processing {
    opacity: 0.7;
}

.file-item.completed {
    border-left: 3px solid var(--accent-success);
}

.file-item.error {
    border-left: 3px solid var(--accent-danger);
}

.file-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-primary);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.file-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.file-progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.file-savings {
    padding: 4px 10px;
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-success);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}

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

.file-actions .btn {
    padding: 4px 8px;
}

/* Editor Panel */
.editor-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.editor-tools {
    display: flex;
    gap: 4px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Compare View */
.compare-container {
    position: relative;
    padding: 20px;
}

.compare-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
}

.label-original,
.label-optimized {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.compare-wrapper {
    position: relative;
    background: repeating-conic-gradient(var(--bg-tertiary) 0% 25%, var(--bg-primary) 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    min-height: 300px;
}

.compare-canvas {
    display: block;
    max-width: 100%;
    max-height: 500px;
    margin: 0 auto;
}

.optimized-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.compare-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    z-index: 10;
}

.slider-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: var(--accent-primary);
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: var(--shadow-md);
    cursor: grab;
}

.slider-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.slider-handle i {
    transform: rotate(90deg);
}

/* Savings Display */
.savings-display {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.savings-content {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
}

.savings-icon {
    width: 48px;
    height: 48px;
    background: rgba(63, 185, 80, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--accent-success);
}

.savings-text {
    display: flex;
    flex-direction: column;
}

.savings-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.savings-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-success);
    line-height: 1;
}

.savings-sizes {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
}

.savings-progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 24px;
    position: sticky;
    top: 20px;
    box-shadow: var(--shadow-md);
}

.settings-section {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

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

.settings-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

/* Format Grid */
.format-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.format-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    border-radius: var(--radius-md);
    text-align: center;
    transition: all 0.2s ease;
}

.format-label i {
    font-size: 24px;
    margin-bottom: 6px;
}

.format-label span {
    font-weight: 600;
    font-size: 14px;
}

.format-label small {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

.btn-check:checked + .format-label {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

/* Quality Slider */
.quality-slider-wrapper {
    padding: 0 8px;
}

.quality-slider {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.quality-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.quality-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.quality-value {
    font-size: 24px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quality-presets {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.quality-preset {
    flex: 1;
}

.quality-preset.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Resize & Palette Options */
.resize-options.disabled,
.palette-options.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.resize-presets,
.palette-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.resize-preset,
.palette-preset {
    font-size: 12px;
}

/* Advanced Settings */
.advanced-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
}

.advanced-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.advanced-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

.advanced-toggle:not(.collapsed) .toggle-icon {
    transform: rotate(180deg);
}

.advanced-content {
    padding: 16px 0;
}

/* Form Elements */
.form-control,
.form-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-select option {
    background: var(--bg-secondary);
}

.form-check-input {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

.form-check-input:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.form-range {
    background: transparent;
}

.form-range::-webkit-slider-track {
    background: var(--bg-tertiary);
}

.form-range::-webkit-slider-thumb {
    background: var(--accent-primary);
}

.input-group-text {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-success), #2ea043);
    border: none;
}

.btn-outline-primary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-primary:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover,
.btn-outline-secondary.active {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.btn-outline-light {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-light:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* Processing Overlay */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    backdrop-filter: blur(4px);
}

.processing-content {
    text-align: center;
    padding: 40px;
}

.processing-spinner {
    margin-bottom: 20px;
}

.processing-spinner .spinner-border {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

.processing-progress {
    width: 300px;
    height: 8px;
    margin: 20px auto;
    background: var(--bg-tertiary);
}

/* Progress Bar */
.progress {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.progress-bar {
    background: var(--accent-gradient);
}

.progress-bar.bg-success {
    background: linear-gradient(90deg, var(--accent-success), #2ea043) !important;
}

/* Toast */
.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.toast-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.toast-body {
    color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Responsive */
@media (max-width: 991px) {
    .settings-panel {
        position: relative;
        top: 0;
        margin-top: 20px;
    }
    
    .editor-tools {
        flex-wrap: wrap;
    }
}

@media (max-width: 575px) {
    .format-grid {
        grid-template-columns: 1fr;
    }
    
    .upload-zone {
        padding: 40px 20px;
    }
    
    .savings-content {
        flex-wrap: wrap;
    }
}

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

.file-item {
    animation: fadeIn 0.3s ease;
}

/* Badge overrides */
.badge {
    font-weight: 500;
}

.badge.bg-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary);
}
