/* ============================================
   WebP Converter — Design System
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a1a;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.07);
    --text-primary: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, 0.55);
    --text-tertiary: rgba(240, 240, 245, 0.35);
    --accent-1: #6c5ce7;
    --accent-2: #a29bfe;
    --accent-3: #00cec9;
    --gradient-start: #6c5ce7;
    --gradient-end: #00cec9;
    --success: #00b894;
    --danger: #fd79a8;
    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Animated Background Blobs --- */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.45;
    will-change: transform;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6c5ce7 0%, transparent 70%);
    top: -10%;
    left: -5%;
    animation: float1 18s ease-in-out infinite;
}

.blob-2 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #00cec9 0%, transparent 70%);
    top: 30%;
    right: -10%;
    animation: float2 22s ease-in-out infinite;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #fd79a8 0%, transparent 70%);
    bottom: -5%;
    left: 30%;
    animation: float3 20s ease-in-out infinite;
}

.blob-4 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #a29bfe 0%, transparent 70%);
    top: 60%;
    left: 10%;
    animation: float4 25s ease-in-out infinite;
}

@keyframes float1 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(80px, 60px) scale(1.1);
    }

    66% {
        transform: translate(-40px, 100px) scale(0.95);
    }
}

@keyframes float2 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(-70px, 80px) scale(1.05);
    }

    66% {
        transform: translate(50px, -60px) scale(1.1);
    }
}

@keyframes float3 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(60px, -40px) scale(1.08);
    }

    66% {
        transform: translate(-80px, -30px) scale(0.9);
    }
}

@keyframes float4 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(100px, -80px) scale(1.12);
    }
}

/* --- Container --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 20px 40px;
}

/* --- Hero --- */
.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 6px 16px;
    border-radius: 50px;
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: var(--accent-2);
    margin-bottom: 20px;
}

.hero h1 {
    font-size: clamp(2.4rem, 6vw, 3.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    font-size: 1.05rem;
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* --- Glassmorphism Card --- */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 32px;
    margin-bottom: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}

/* --- Upload / Drop Zone --- */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-2);
    background: rgba(108, 92, 231, 0.06);
}

.drop-zone.drag-over .drop-icon {
    transform: translateY(-6px) scale(1.15);
    color: var(--accent-2);
}

.drop-icon {
    color: var(--text-secondary);
    margin-bottom: 16px;
    transition: all var(--transition);
}

.drop-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.drop-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.drop-formats {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* --- Controls --- */
.controls-card {
    transition: all 0.5s ease;
}

.controls-row {
    display: flex;
    gap: 24px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.quality-control {
    flex: 1;
    min-width: 200px;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.quality-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
}

/* Custom Range Slider */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    transition: background var(--transition);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    cursor: pointer;
    border: 3px solid var(--bg-dark);
    box-shadow: 0 0 12px rgba(108, 92, 231, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.6);
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    cursor: pointer;
    border: 3px solid var(--bg-dark);
    box-shadow: 0 0 12px rgba(108, 92, 231, 0.4);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-weight: 500;
}

/* === Convert Button === */
.btn-convert {
    padding: 14px 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-convert::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-convert:hover::before {
    opacity: 1;
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.4);
}

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

.btn-convert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* --- File List (pre-conversion) --- */
.file-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    animation: fadeInUp 0.3s ease forwards;
}

.file-item-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.file-item-size {
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}

.file-item-remove:hover {
    color: var(--danger);
}

/* --- Results --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-download-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid rgba(0, 206, 201, 0.3);
    border-radius: var(--radius-xs);
    background: rgba(0, 206, 201, 0.08);
    color: var(--accent-3);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-download-all:hover {
    background: rgba(0, 206, 201, 0.15);
    border-color: rgba(0, 206, 201, 0.5);
    transform: translateY(-1px);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Individual Result Item */
.result-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 20px;
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.result-item-top {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
}

.result-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

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

.result-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}

.result-sizes {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.result-arrow {
    color: var(--accent-3);
}

.result-new-size {
    font-weight: 600;
    color: var(--accent-3);
}

.result-savings {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
}

.savings-positive {
    background: rgba(0, 184, 148, 0.12);
    color: var(--success);
}

.savings-negative {
    background: rgba(253, 121, 168, 0.12);
    color: var(--danger);
}

.quality-auto-note {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(162, 155, 254, 0.12);
    color: var(--accent-2);
    cursor: help;
}

/* Comparison Bar */
.result-bar-wrapper {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 14px;
}

.result-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-actions {
    display: flex;
    gap: 10px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-xs);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.35);
}

.btn-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-preview:hover {
    background: var(--glass-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- Spinner --- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* --- Preview Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.modal-content {
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    max-width: 90vw;
    max-height: 85vh;
    overflow: auto;
    padding: 24px;
    position: relative;
    animation: scaleIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal-comparison {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.modal-comparison>div {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.modal-comparison img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: rgba(255, 255, 255, 0.02);
}

.modal-comparison p {
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

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

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.delay-1 {
    animation-delay: 0.1s;
    opacity: 0;
}

.delay-2 {
    animation-delay: 0.2s;
    opacity: 0;
}

.delay-3 {
    animation-delay: 0.3s;
    opacity: 0;
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 24px 0 0;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container {
        padding: 36px 14px 24px;
    }

    .glass-card {
        padding: 20px;
    }

    .drop-zone {
        padding: 36px 16px;
    }

    .controls-row {
        flex-direction: column;
    }

    .btn-convert {
        width: 100%;
        text-align: center;
    }

    .modal-comparison {
        flex-direction: column;
    }

    .result-item-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-thumb {
        width: 100%;
        height: auto;
        max-height: 160px;
    }

    .blob {
        opacity: 0.25;
    }
}