:root {
    --bg-color: #0d1117;
    --container-bg: rgba(22, 27, 34, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary-color: #58a6ff;
    --primary-hover: #79c0ff;
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --accent-color: #2ea043;
    --highlight-bg: rgba(46, 160, 67, 0.15);
    --danger-color: #f85149;
    --glass-blur: blur(16px);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Decorations (Aesthetic) */
.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
}

.sphere-1 {
    width: 600px;
    height: 600px;
    background: var(--primary-color);
    top: -200px;
    left: -100px;
    animation: float 20s ease-in-out infinite alternate;
}

.sphere-2 {
    width: 500px;
    height: 500px;
    background: #8a2be2;
    bottom: -150px;
    right: -100px;
    animation: float 25s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(50px) scale(1.1); }
}

/* App Container (Glassmorphism) */
.app-container {
    width: 95%;
    max-width: 1100px;
    margin: 40px auto;
    background: var(--container-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Typography & Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 10px;
    color: #fff;
}

h1 span {
    background: linear-gradient(135deg, var(--primary-color), #8a2be2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #fff;
    font-weight: 600;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: rgba(0,0,0,0.2);
}

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

.upload-zone input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 15px;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 5px;
}

.upload-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.supported-formats {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Workspace Layout */
.workspace {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    opacity: 1;
    transform: translateY(0);
    transition: var(--transition);
}

.workspace.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

/* Settings Panel */
.settings-panel {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-header label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
}

#qualityValue {
    font-family: monospace;
    color: var(--primary-color);
    background: rgba(88, 166, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Custom Range Input */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
    transition: transform 0.1s;
}

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

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

.setting-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: var(--text-muted);
}
.status-badge.working {
    background: rgba(88, 166, 255, 0.2);
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}
.status-badge.done {
    background: rgba(46, 160, 67, 0.2);
    color: var(--accent-color);
}
.status-badge.error {
    background: rgba(248, 81, 73, 0.2);
    color: var(--danger-color);
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Preset Pills & Custom Input */
.preset-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}

.preset-pill {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    width: auto;
}

.preset-pill:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.preset-pill.active {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.custom-size-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.custom-size-wrapper input {
    width: 100%;
    padding: 12px;
    padding-right: 40px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.custom-size-wrapper input:focus {
    border-color: var(--primary-color);
    background: rgba(0,0,0,0.5);
}

.size-unit {
    position: absolute;
    right: 15px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* Select Input */
select {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    appearance: none;
}

select:focus {
    border-color: var(--primary-color);
}

select option {
    background: var(--bg-color);
    color: #fff;
}

/* Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 166, 255, 0.4);
}

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

.secondary-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

/* Preview Panel */
.preview-panel {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
}

.image-box {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.badge {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
}

.original-badge {
    background: rgba(0,0,0,0.6);
    color: #fff;
}

.compressed-badge {
    background: rgba(46, 160, 67, 0.8);
    color: #fff;
}

.image-box img {
    width: 100%;
    height: 250px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 15px;
    background: transparent;
    border: 1px inset rgba(255,255,255,0.05);
}

.stats {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.stat-label {
    color: var(--text-muted);
}

.highlight-stat {
    color: var(--accent-color);
    font-weight: 600;
}

.savings {
    margin-left: auto;
    background: var(--highlight-bg);
    color: var(--accent-color);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.savings.negative {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger-color);
}

.dimension-stat {
    background: rgba(255,255,255,0.02);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
}

/* Responsive Design */
@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .comparison-container {
        grid-template-columns: 1fr;
    }
    
    .image-box img {
        height: 200px;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 20px;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin: 0;
        min-height: 100vh;
    }

    h1 {
        font-size: 2.2rem;
    }
}
