:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
}

.main-content {
    margin-left: 280px;
    padding: 30px;
    max-width: 1000px;
    margin-right: auto;
}

.tool-header {
    text-align: center;
    margin-bottom: 30px;
}

.tool-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tool-header p {
    color: var(--text-muted);
}

/* Upload Style */
.upload-section {
    max-width: 600px;
    margin: 40px auto;
}

.upload-card {
    background: white;
    padding: 50px;
    border-radius: 24px;
    border: 2px dashed var(--border-color);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-card:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

/* Main Tool Container */
.tool-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Preview Card - Top Section */
.preview-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.preview-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
}

.file-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.stats-container {
    display: flex;
    gap: 30px;
}

.stat-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #000;
}

.save-badge {
    color: var(--success-color);
    font-size: 0.85rem;
    margin-left: 5px;
}

.warning-badge {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
}

.warning-badge i {
    font-size: 0.85rem;
}

/* Preview Content - Grid */
.preview-content {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 20px;
    height: 450px;
}

.comparison-area {
    background: #f8fafc;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    border: 1px solid #f1f5f9;
    cursor: grab;
}

.comparison-area.grabbing {
    cursor: grabbing;
}

.image-comparison {
    width: 100%;
    height: 100%;
    position: relative;
}

.image-before,
.image-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.image-before img,
.image-after img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8fafc;
    transition: transform 0.1s ease-out;
    transform-origin: center;
    pointer-events: none;
    user-select: none;
}

.image-after {
    width: 100%;
    z-index: 2;
    overflow: hidden;
    clip-path: inset(0 0 0 50%);
    pointer-events: none;
    /* Let clicks pass to comparison area for panning */
}

.comparison-slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #fff;
    z-index: 10;
    pointer-events: auto;
    /* Enable dragging the line too */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.comparison-area:hover .comparison-slider {
    opacity: 1;
}

.slider-handle {
    position: absolute;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--primary-color);
    z-index: 12;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1), background 0.2s;
    cursor: ew-resize;
    pointer-events: auto;
}

/* Right Control Panel within Preview */
.integrated-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
}

.quality-box {
    margin-bottom: 15px;
    text-align: center;
}

.quality-box label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.quality-box input {
    width: 60px;
    height: 35px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    outline: none;
}

.vertical-slider-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    position: relative;
}

.slider-pct {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.vertical-slider-container input[type="range"] {
    writing-mode: bt-lr;
    /* Bottom to top */
    appearance: slider-vertical;
    -webkit-appearance: slider-vertical;
    width: 8px;
    height: 200px;
    background: #e2e8f0;
    border-radius: 10px;
    outline: none;
}

.slider-icon {
    font-size: 0.9rem;
    color: #94a3b8;
}

.apply-btn {
    width: 100%;
    height: 40px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 15px;
}

.apply-btn:hover {
    background: #000;
}

/* Bottom Controls */
.bottom-controls {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-card);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 25px;
}

.setting-group h3 {
    font-size: 0.9rem;
    margin-bottom: 15px;
    color: var(--text-main);
}

.mode-options-horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mode-pill {
    padding: 8px 16px;
    border-radius: 100px;
    background: #f1f5f9;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.mode-pill.active {
    background: #eff6ff;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.mode-pill input {
    display: none;
}

.mode-extra-controls {
    height: auto;
    margin-top: 10px;
}

.max-size-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    max-width: 320px;
}

.max-size-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px !important;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.max-size-header i {
    color: #94a3b8;
    font-size: 0.9rem;
}

.input-inline {
    display: flex;
    gap: 10px;
}

.input-inline input {
    width: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    outline: none;
}

.input-inline select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: white;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.format-select select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-size: 0.85rem;
}

.hint-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
    max-width: 200px;
}

/* Global Actions */
.global-actions {
    display: flex;
    gap: 15px;
}

.download-btn-filled {
    flex: 2;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.download-btn-filled:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.new-image-btn {
    flex: 1;
    background: white;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.new-image-btn:hover {
    background: #f8fafc;
}

/* Helpers */
.hidden {
    display: none !important;
}

.hidden-control {
    display: none;
}

.hidden-control.active {
    display: block;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        margin-left: 0;
    }

    .preview-content {
        grid-template-columns: 1fr;
        height: auto;
    }

    .comparison-area {
        height: 350px;
    }

    .integrated-controls {
        flex-direction: row;
        justify-content: space-around;
        padding: 20px 0;
    }

    .vertical-slider-container input[type="range"] {
        height: 8px;
        width: 150px;
        appearance: slider-horizontal;
        -webkit-appearance: slider-horizontal;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}