/*
    WebP Converter – Utility Page
    ══════════════════════════════════════════════════
    Parte della sezione "Lab & Utility" di AttilioViscido.it

    DESIGN SYSTEM:
    Questo foglio di stile ridefinisce localmente le stesse variabili
    del sito principale (NON le importa con @import), così ogni utility
    è autonoma e trasportabile senza dipendenze esterne dal sito.

    Per una nuova utility: copia il blocco :root e le classi
    .bg-grid, .bg-glow, .site-header, .back-link, .app-wrapper
    come base di partenza, poi aggiungi i tuoi stili specifici.

    Palette (identica al sito principale css/style.css):
      --primary:       #076FB7  (blu brand B.I. Strategy)
      --primary-light: #2A8CD4  (hover/gradiente)
      --accent:        #D3B574  (oro per accenti premium)
      --dark-bg:       #0D1117  (sfondo scuro, stile GitHub Dark)
      --card-bg:       #161B22  (sfondo card e contenitori)
      --text-main:     #c9d1d9  (testo su sfondo scuro)
*/

/* ── Design tokens ─────────────────────────────── */
/* Stesse variabili del sito principale, ridefinite localmente per autonomia */
:root {
    --primary: #076FB7;
    --primary-light: #2A8CD4;
    --accent: #D3B574;
    --accent-hover: #b89a57;
    --dark-bg: #0D1117;
    --card-bg: #161B22;
    --card-border: rgba(211, 181, 116, 0.15);
    --text-main: #c9d1d9;
    --text-white: #ffffff;
    --text-muted: #8b949e;
    --error: #f85149;
    --success: #3fb950;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Reset & base ───────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ── Animated background ────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(7, 111, 183, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 111, 183, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

/*
    Sfere di luce sfocate (glow) con animazione fluttuante.
    glow-1 = sfera blu (in alto a destra)
    glow-2 = sfera oro (in basso a sinistra)
*/
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: driftGlow 18s ease-in-out infinite alternate;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -80px;
    left: -80px;
    animation-delay: -9s;
    opacity: 0.1;
}

@keyframes driftGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-40px, 40px) scale(1.1);
    }

    100% {
        transform: translate(40px, -20px) scale(0.95);
    }
}

/* ── Compact Site Header ────────────────────────── */
/*
    Header ridotto (60px) che sostituisce il nav completo del sito.
    Mostra il link di ritorno alla home e un breadcrumb "Lab & Utility".
    DEVE essere presente in TUTTE le utility per coerenza di navigazione.
*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.back-link i {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: var(--transition);
}

.back-link:hover i {
    transform: translateX(-3px);
    opacity: 1;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-white);
}

.logo-dot {
    color: var(--accent);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.breadcrumb i {
    color: var(--accent);
    font-size: 0.8rem;
}

/* ── Main Wrapper ───────────────────────────────── */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    padding: 90px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ── App Card ───────────────────────────────────── */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 36px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── App Header ─────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-icon-wrap {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 1.4rem;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(7, 111, 183, 0.4);
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-white);
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.reset-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    padding: 9px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.reset-btn:hover {
    color: var(--accent);
    background: rgba(211, 181, 116, 0.1);
    border-color: var(--accent);
}

/* ── Drop Zone ──────────────────────────────────── */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(7, 111, 183, 0.07);
    box-shadow: 0 0 0 4px rgba(7, 111, 183, 0.12);
}

.drop-zone.drag-over {
    border-style: solid;
    border-color: var(--accent);
    background: rgba(211, 181, 116, 0.05);
    box-shadow: 0 0 0 4px rgba(211, 181, 116, 0.1);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.drop-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(7, 111, 183, 0.2), rgba(42, 140, 212, 0.1));
    border: 1px solid rgba(7, 111, 183, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--primary-light);
    margin-bottom: 6px;
    transition: var(--transition);
}

.drop-zone.drag-over .drop-icon {
    background: rgba(211, 181, 116, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.1);
}

.drop-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
}

.drop-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.browse-btn {
    pointer-events: all;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(7, 111, 183, 0.35);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.browse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(7, 111, 183, 0.5);
}

.drop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 4px;
}

/* ── Controls Section ───────────────────────────── */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.controls-section.hidden {
    display: none;
}

/* ── Preview ────────────────────────────────────── */
.preview-wrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    max-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    display: block;
}

.preview-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-badge i {
    color: var(--accent);
}

/* ── Format Row ─────────────────────────────────── */
.format-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.format-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.format-label i {
    color: var(--primary-light);
}

/* ── Type Selector pills (same pattern as qrcode) ── */
.type-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 5px;
    gap: 5px;
}

.type-selector input[type="radio"] {
    display: none;
}

.selector-btn {
    flex: 1;
    text-align: center;
    padding: 9px 20px;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}

.type-selector input[type="radio"]:checked+.selector-btn {
    color: var(--text-white);
    background: var(--primary);
    box-shadow: 0 4px 15px rgba(7, 111, 183, 0.35);
}

/* ── Quality Slider ─────────────────────────────── */
.quality-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    transition: var(--transition);
}

.quality-row.hidden {
    display: none;
}

.quality-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quality-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

.slider-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--text-white);
    box-shadow: 0 2px 8px rgba(7, 111, 183, 0.5);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--primary-light);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--text-white);
    box-shadow: 0 2px 8px rgba(7, 111, 183, 0.5);
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ── Convert Button ─────────────────────────────── */
.convert-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(7, 111, 183, 0.35);
    letter-spacing: 0.02em;
}

.convert-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(7, 111, 183, 0.5);
}

.convert-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

.convert-btn.converting {
    opacity: 0.75;
    cursor: wait;
}

.btn-icon {
    color: var(--accent);
    transition: var(--transition);
    font-size: 0.9rem;
}

.convert-btn:hover .btn-icon {
    transform: scale(1.3) rotate(10deg);
}

/* ── Success Toast ──────────────────────────────── */
.success-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
    animation: fadeIn 0.4s ease;
}

.success-toast.hidden {
    display: none;
}

.success-toast i {
    font-size: 1.1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Privacy note ───────────────────────────────── */
.privacy-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.privacy-note i {
    color: var(--accent);
    opacity: 0.8;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 520px) {
    .app-card {
        padding: 24px 18px;
        border-radius: 20px;
        gap: 22px;
    }

    .app-header h1 {
        font-size: 1.35rem;
    }

    .site-header-inner {
        padding: 0 16px;
    }

    .breadcrumb {
        display: none;
    }

    .format-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}