/* ===========================================
   OPTIMIZADOR v2 — Beplan dark-theme
   Fonts: Jost (títulos) + Roboto (cuerpo)
   Accent: #FF4D63
   =========================================== */

:root {
    --bg:           #15181b;
    --surface:      #1d2024;
    --surface-2:    #23262a;
    --border:       rgba(255, 255, 255, 0.07);
    --border-md:    rgba(255, 255, 255, 0.13);
    --accent:       #FF4D63;
    --accent-glow:  rgba(255, 77, 99, 0.18);
    --text:         #eceae6;
    --text-2:       #8b9098;
    --text-3:       #4a5058;
    --green:        #34d399;
    --green-dim:    rgba(52, 211, 153, 0.10);
    --red-dim:      rgba(239, 68, 68, 0.08);
    --yellow-dim:   rgba(245, 158, 11, 0.08);
    --font-h:       'Jost', sans-serif;
    --font-b:       'Roboto', sans-serif;
    --r-sm:         6px;
    --r-md:         10px;
    --r-lg:         16px;
    --r-xl:         20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-b);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.site-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.site-logo img {
    height: 26px;
    width: auto;
    display: block;
    filter: brightness(0) invert(1);
}

.tool-id {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-sep {
    color: var(--text-3);
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
}

.tool-name {
    font-family: var(--font-h);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.02em;
}

.tool-badge {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(255, 77, 99, 0.28);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-h);
    padding: 1px 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ---- Main ---- */
.app-main {
    flex: 1;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 20px 56px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---- Upload Panel ---- */
.upload-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.upload-zone {
    border: 1.5px dashed var(--border-md);
    border-radius: var(--r-xl);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
    outline: none;
}

.upload-zone:hover,
.upload-zone:focus-visible {
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.upload-zone.is-dragover {
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 0 0 5px var(--accent-glow);
    transform: scale(1.003);
}

.upload-zone__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    text-align: center;
    gap: 10px;
}

.upload-zone__icon {
    color: var(--accent);
    opacity: 0.85;
    margin-bottom: 4px;
}

.upload-zone__title {
    font-family: var(--font-h);
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
}

.upload-zone__formats {
    font-size: 12px;
    color: var(--text-3);
    letter-spacing: 0.06em;
    font-family: var(--font-h);
    text-transform: uppercase;
    font-weight: 500;
}

.upload-zone__hints {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

kbd {
    display: inline-block;
    padding: 1px 5px;
    background: var(--surface-2);
    border: 1px solid var(--border-md);
    border-radius: 3px;
    font-size: 11px;
    font-family: var(--font-b);
    color: var(--text-2);
    line-height: 1.6;
}

.btn-upload {
    margin-top: 6px;
    padding: 10px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--font-h);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    letter-spacing: 0.03em;
}

.btn-upload:hover { opacity: 0.86; transform: translateY(-1px); }

/* ---- Settings Bar ---- */
.settings-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 20px;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}

.setting__label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-family: var(--font-h);
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.setting__label strong {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

/* Range */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: var(--border-md);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Select */
select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background-color: var(--surface-2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%234a5058' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--font-b);
    font-size: 13px;
    padding: 8px 32px 8px 12px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

select:focus { border-color: var(--accent); }
select option { background: var(--surface-2); }

/* ---- Processing ---- */
.processing {
    padding: 64px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: fadeUp 0.2s ease-out;
}

.processing__bar {
    width: 100%;
    max-width: 420px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.processing__fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.processing__text {
    font-size: 13px;
    color: var(--text-2);
    font-family: var(--font-h);
    font-weight: 500;
    letter-spacing: 0.01em;
    max-width: 400px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Results ---- */
.results {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeUp 0.25s ease-out;
}

.results__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.results__stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rs-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 16px;
    min-width: 80px;
}

.rs-pill--opt {
    border-color: rgba(255, 77, 99, 0.22);
    background: rgba(255, 77, 99, 0.04);
}

.rs-pill--saved {
    border-color: rgba(52, 211, 153, 0.22);
    background: var(--green-dim);
}

.rs-num {
    font-family: var(--font-h);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.rs-pill--saved .rs-num { color: var(--green); }
.rs-pill--opt .rs-num   { color: var(--accent); }

.rs-lbl {
    font-size: 10px;
    color: var(--text-3);
    font-family: var(--font-h);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.rs-sep {
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.rs-divider {
    width: 1px;
    height: 34px;
    background: var(--border);
    flex-shrink: 0;
}

.results__actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Select + button fused group */
.dl-all-group {
    display: flex;
    align-items: stretch;
}

.select-zip {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--surface-2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234a5058' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    border: 1px solid rgba(255, 77, 99, 0.35);
    border-right: none;
    border-radius: 50px 0 0 50px;
    color: var(--text-2);
    font-family: var(--font-h);
    font-size: 12px;
    font-weight: 500;
    padding: 0 28px 0 13px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, color 0.2s;
    white-space: nowrap;
    min-width: 0;
}

.select-zip:focus {
    border-color: var(--accent);
    color: var(--text);
}

.select-zip option { background: var(--surface-2); }

.dl-all-group .btn-primary {
    border-radius: 0 50px 50px 0;
}

/* ---- Buttons ---- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--font-h);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.btn-primary:hover { opacity: 0.86; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; pointer-events: none; }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-md);
    border-radius: 50px;
    font-family: var(--font-h);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.btn-ghost:hover {
    border-color: var(--text-2);
    color: var(--text);
    background: var(--surface);
}

/* ---- Images Grid ---- */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 14px;
}

/* ---- Image Card ---- */
.img-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.img-card:hover {
    border-color: var(--border-md);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.img-card__thumb {
    width: 100%;
    height: 155px;
    object-fit: cover;
    display: block;
    background: var(--surface-2);
}

.img-card__body {
    padding: 14px 15px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.img-card__name {
    font-family: var(--font-h);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.img-card__dims {
    font-family: var(--font-h);
    font-size: 11px;
    color: var(--text-2);
    margin-top: -4px;
}

/* Compression bar */
.comp-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.comp-bar-track {
    height: 5px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.comp-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    width: 0%;
}

.comp-bar-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--font-h);
}

.comp-pct {
    color: var(--green);
    font-weight: 700;
}

/* Format download buttons */
.img-card__formats {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.btn-dl {
    flex: 1;
    min-width: 70px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 8px;
    border-radius: var(--r-sm);
    font-family: var(--font-h);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.btn-dl:hover { opacity: 0.82; transform: translateY(-1px); }

.btn-dl--webp {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.btn-dl--avif {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.btn-dl--orig {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(255, 77, 99, 0.2);
}

.btn-dl--single {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border-md);
}

.btn-dl__size {
    opacity: 0.65;
    font-weight: 400;
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
}

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    border-radius: var(--r-md);
    font-size: 13px;
    margin-bottom: 14px;
    animation: fadeUp 0.2s ease-out;
    border: 1px solid;
}

.alert--error {
    background: var(--red-dim);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert--warning {
    background: var(--yellow-dim);
    border-color: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.alert span { flex: 1; }

.alert__close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.alert__close:hover { opacity: 1; }

/* ---- Footer ---- */
.site-footer {
    padding: 18px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-3);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.site-footer a {
    color: var(--text-2);
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer a:hover { color: var(--accent); }

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.spin { animation: spin 0.7s linear infinite; display: inline-block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-main { padding: 20px 16px 48px; }

    .upload-zone__body { padding: 36px 16px; }

    .settings-bar { padding: 14px 16px; gap: 12px; }
    .setting { min-width: 100%; }

    .results__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results__actions {
        width: 100%;
    }

    .results__actions .btn-ghost {
        flex: 1;
        justify-content: center;
    }

    .dl-all-group {
        flex: 1;
    }

    .select-zip {
        flex: 1;
    }

    .dl-all-group .btn-primary {
        flex-shrink: 0;
    }

    .images-grid {
        grid-template-columns: 1fr;
    }

    .rs-divider { display: none; }
}

@media (max-width: 480px) {
    .site-header { padding: 0 16px; }

    .results__stats {
        justify-content: center;
        width: 100%;
    }

    .rs-sep { display: none; }
    .rs-pill { min-width: 72px; }

    .upload-zone__hints { font-size: 11px; }
}
