/* ==========================================================================
   Zuply Squoosh Batch - Estilos Customizados com Variável Global de Tema
   ========================================================================== */

:root {
    color-scheme: dark;
    /* Variável Global de Cor do Tema (Extraída do "S" da logo Zuply: #e92c4d) */
    --theme-color-rgb: 233, 44, 77;
    --secundary-color-rgb: 0, 157, 255;
    --theme-color: #e92c4d;
    --theme-color-hover: #d42342;
    --secundary-color: #009dff;
    --secundary-color-hover: #0084d6;
    --theme-color-soft: rgba(var(--theme-color-rgb), 0.78);
    --theme-color-muted: rgba(var(--theme-color-rgb), 0.18);
    --theme-color-border: rgba(var(--theme-color-rgb), 0.42);

    --squoosh-dark: #13151a;
    --squoosh-card: rgba(30, 33, 40, 0.96);
    --squoosh-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

input, select, textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* Classes utilitárias vinculadas à variável global --theme-color */
.bg-theme {
    background-color: var(--theme-color) !important;
}

.bg-theme-soft {
    background-color: var(--theme-color-soft) !important;
}

.bg-theme-muted {
    background-color: var(--theme-color-muted) !important;
}

.hover-bg-theme:hover {
    background-color: var(--theme-color-hover) !important;
}

.text-theme {
    color: var(--theme-color) !important;
}

.border-theme {
    border-color: var(--theme-color) !important;
}

.border-theme-soft {
    border-color: var(--theme-color-border) !important;
}

/* Fundo xadrez clássico de transparência (estilo Squoosh) */
.checkerboard-bg {
    background-color: #1e2026;
    background-image:
        linear-gradient(45deg, #282b33 25%, transparent 25%),
        linear-gradient(-45deg, #282b33 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #282b33 75%),
        linear-gradient(-45deg, transparent 75%, #282b33 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.checkerboard-sm {
    background-color: #1a1d24;
    background-image:
        linear-gradient(45deg, #252932 25%, transparent 25%),
        linear-gradient(-45deg, #252932 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #252932 75%),
        linear-gradient(-45deg, transparent 75%, #252932 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

/* Painéis com Glassmorphism escuro */
.squoosh-glass {
    background: var(--squoosh-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--squoosh-border);
}

/* Cabeçalhos (Edit / Compress) com a cor avermelhada da logo e opacidade suave para não carregar */
.squoosh-section-header {
    background: linear-gradient(
        90deg,
        rgba(var(--secundary-color-rgb), 0.76) 0%,
        rgba(var(--secundary-color-rgb), 0.56) 100%
    );
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(var(--secundary-color-rgb), 0.35);
    color: #ffffff;
}

/* Divisor Antes / Depois (Split Slider) */
.split-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 20;
}

.split-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    background: var(--theme-color-soft);
    backdrop-filter: blur(6px);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 20px rgba(var(--theme-color-rgb), 0.5), 0 2px 8px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ew-resize;
    pointer-events: auto;
    transition: transform 0.15s ease, background-color 0.15s ease;
    z-index: 25;
}

.split-handle:hover,
.split-handle.dragging {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--theme-color);
}

/* Estilização dos Range Sliders usando a variável global do tema */
input[type="range"].squoosh-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    outline: none;
}

input[type="range"].squoosh-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--theme-color);
    border: 2px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--theme-color-rgb), 0.55);
    transition: transform 0.12s ease, background-color 0.12s ease;
}

input[type="range"].squoosh-range::-webkit-slider-thumb:hover {
    transform: scale(1.18);
    background: var(--theme-color-hover);
}

input[type="range"].squoosh-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--theme-color);
    border: 2px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--theme-color-rgb), 0.55);
    transition: transform 0.12s ease;
}

/* Input numérico da qualidade afastado da setinha com fundo escuro */
.quality-number-input {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
    color-scheme: dark;
}

.quality-number-input::-webkit-inner-spin-button,
.quality-number-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quality-stepper-box {
    display: flex;
    flex-direction: column;
    background-color: #13161c;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

.quality-stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 13px;
    background-color: #181c24;
    color: #cbd5e1;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.quality-stepper-btn:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.quality-stepper-btn:hover {
    background-color: #2b313f;
    color: #ffffff;
}

.quality-stepper-btn:active {
    background-color: var(--secundary-color);
    color: #0f172a;
}

/* Badge seta estilo Squoosh: [ ↓ 81% | 12.0 kB ] com a cor do tema suavizada */
.squoosh-savings-arrow {
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
    padding-right: 18px;
    background: rgba(var(--theme-color-rgb), 0.82);
    color: #ffffff;
}

/* Botão de Download Orgânico com Blob Duplo na cor do tema com opacidade suave */
@keyframes blobSpinSlow {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.06);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

.squoosh-dl-btn-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.squoosh-dl-blob-1 {
    position: absolute;
    inset: 0;
    background: rgba(var(--theme-color-rgb), 0.55);
    border-radius: 46% 54% 52% 48% / 48% 44% 56% 52%;
    animation: blobSpinSlow 7s linear infinite;
}

.squoosh-dl-blob-2 {
    position: absolute;
    inset: 3px;
    background: rgba(var(--theme-color-rgb), 0.86);
    border-radius: 54% 46% 44% 56% / 52% 56% 44% 48%;
    animation: blobSpinSlow 5s linear infinite reverse;
}

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

::-webkit-scrollbar-track {
    background: rgba(15, 17, 22, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Animação do Dropzone estilo Squoosh */
@keyframes pulseRing {
    0% {
        transform: scale(0.97);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.03);
        opacity: 1;
    }
    100% {
        transform: scale(0.97);
        opacity: 0.7;
    }
}

.dropzone-blob {
    animation: pulseRing 5s ease-in-out infinite;
}

/* Renderização pixelada opcional no zoom */
.pixelated-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
