:root {
    --bg-dark: #090b0f;
    --bg-panel: rgba(17, 22, 32, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --panel-radius: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    --divider-pos: 50%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Loading Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#app-container:not(.loading) .loader-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loader-overlay p {
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
}

.header-badge {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

/* Main Container */
main {
    flex: 1;
    padding: 40px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Panel style */
.glass {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    padding: 28px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

/* Upload Zone */
.drop-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--panel-radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    position: relative;
    background-color: rgba(255, 255, 255, 0.01);
    transition: var(--transition);
    min-height: 450px;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.03);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.05);
}

.drop-zone input[type="file"] {
    display: none;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--primary);
    margin: 0 auto 24px auto;
    transition: var(--transition);
}

.drop-zone:hover .icon-circle {
    transform: translateY(-5px);
    background-color: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.drop-zone h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* Workspace Grid */
.workspace-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 32px;
    align-items: start;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
    height: fit-content;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-section label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* Custom Select Dropdown */
.select-wrapper {
    position: relative;
    width: 100%;
}

select {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
}

select:hover, select:focus {
    border-color: var(--border-hover);
    background-color: rgba(255, 255, 255, 0.06);
    outline: none;
}

.select-chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: var(--text-muted);
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Control Groups */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.control-badge {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

.size-input-wrapper {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px 8px;
}

.size-input-wrapper input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 13px;
    width: 60px;
    text-align: right;
    outline: none;
}

.size-input-wrapper .unit {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

.control-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Custom Input Range */
input[type="range"] {
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    outline: none;
    margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-gradient);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-success {
    background-color: var(--success);
    color: white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

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

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: var(--border-hover);
}

.panel-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.stat-card.highlight {
    border-color: rgba(16, 185, 129, 0.3);
    background-color: rgba(16, 185, 129, 0.02);
}

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

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.stat-type, .stat-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-card.highlight .stat-sub {
    color: var(--success);
    font-weight: 600;
}

/* Comparison Slider */
.comparison-container-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comparison-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.comparison-slider {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.comparison-slider.uncompressed .compressed-layer,
.comparison-slider.uncompressed .slider-handle,
.comparison-slider.uncompressed .image-label-tag {
    display: none !important;
}

.image-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-drag: none;
}

.image-layer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.original-layer {
    z-index: 1;
}

.compressed-layer {
    z-index: 2;
    clip-path: inset(0 0 0 var(--divider-pos));
}

.image-label-tag {
    position: absolute;
    bottom: 16px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 10;
}

.tag-left {
    left: 16px;
    color: var(--text-primary);
}

.tag-right {
    right: 16px;
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Slider Handle Bar */
.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--divider-pos);
    transform: translateX(-50%);
    width: 4px;
    background-color: white;
    z-index: 3;
    cursor: ew-resize;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.handle-line {
    flex: 1;
    width: 1px;
    background-color: rgba(255, 255, 255, 0.5);
}

.handle-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: white;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin: 12px 0;
    border: 2px solid var(--primary);
}

/* Footer */
footer {
    padding: 30px 40px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    
    header {
        padding: 20px;
    }
    
    main {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .mode-tabs {
        flex-direction: column;
    }
}
