/* =========================================================
   imgtools.css — Stile condiviso TOOL IMMAGINI
   Analisiseo 2026 · v3
   -----------------------------------------------------------
   Usato da tutta la famiglia Tool Immagini (IM01..IM08).
   Abbinato al motore condiviso theme/default/js/imgtools.js.
   Tutto scoped sotto .as-imgtool: nessun impatto su altre
   pagine. Si somma a tools.css (gia' attivo sulle pagine tool).
   Caricato con <link> direttamente dalla view del tool.
   ========================================================= */

.as-imgtool {
    margin: 6px 0 10px;
}

/* ---------------------------------------------------------
   1) DROPZONE — area di caricamento classica e chiara
   --------------------------------------------------------- */
.as-imgtool .imgt-drop {
    position: relative;
    display: block;
    border: 2px dashed var(--as-border, #E3E1EE);
    border-radius: 16px;
    background: var(--as-bg, #FBFBFD);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.22s ease;
}
.as-imgtool .imgt-drop:hover {
    border-color: var(--as-primary-2, #7D70F7);
    background: #fff;
    box-shadow: 0 6px 18px rgba(91, 84, 240, 0.08);
}
.as-imgtool .imgt-drop.is-over {
    border-color: var(--as-primary, #5B54F0);
    background: var(--as-primary-soft, #ECEAFF);
}
.as-imgtool .imgt-drop input[type="file"] {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    overflow: hidden;
}
.as-imgtool .imgt-drop-icon {
    width: 54px; height: 54px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--as-primary-soft, #ECEAFF);
    color: var(--as-primary, #5B54F0);
    display: flex;
    align-items: center;
    justify-content: center;
}
.as-imgtool .imgt-drop-icon svg { width: 26px; height: 26px; }
.as-imgtool .imgt-drop-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--as-text, #14131A);
    margin: 0 0 4px;
}
.as-imgtool .imgt-drop-sub {
    font-size: 13.5px;
    color: var(--as-text-soft, #5D5B6B);
    margin: 0;
}

/* ---------------------------------------------------------
   2) CARD DI LAVORO (anteprima + risultato)
   --------------------------------------------------------- */
.as-imgtool .imgt-work {
    display: none;
    border: 1px solid var(--as-border, #E3E1EE);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(20, 19, 26, 0.04);
    overflow: hidden;
}
.as-imgtool.is-loaded .imgt-work { display: block; }
.as-imgtool.is-loaded .imgt-drop { display: none; }

.as-imgtool .imgt-preview-wrap {
    background:
        linear-gradient(45deg, #F1F0F7 25%, transparent 25%, transparent 75%, #F1F0F7 75%),
        linear-gradient(45deg, #F1F0F7 25%, #fff 25%, #fff 75%, #F1F0F7 75%);
    background-size: 22px 22px;
    background-position: 0 0, 11px 11px;
    text-align: center;
    padding: 18px;
    border-bottom: 1px solid var(--as-border, #E3E1EE);
}
.as-imgtool .imgt-preview-wrap img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(20, 19, 26, 0.12);
}
.as-imgtool .imgt-filename {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12.5px;
    color: var(--as-text-soft, #5D5B6B);
    padding: 10px 20px 0;
    word-break: break-all;
}

/* ---------------------------------------------------------
   3) RIGA RISULTATO — prima / dopo / risparmio
   --------------------------------------------------------- */
.as-imgtool .imgt-result {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 20px 6px;
}
.as-imgtool .imgt-chip {
    border: 1px solid var(--as-border, #E3E1EE);
    background: var(--as-bg, #FBFBFD);
    border-radius: 12px;
    padding: 10px 16px;
    text-align: center;
    min-width: 128px;
}
.as-imgtool .imgt-chip small {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--as-text-soft, #5D5B6B);
    margin-bottom: 2px;
}
.as-imgtool .imgt-chip strong {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 16.5px;
    color: var(--as-text, #14131A);
}
.as-imgtool .imgt-arrow {
    color: var(--as-primary, #5B54F0);
    font-size: 20px;
    font-weight: 700;
}
.as-imgtool .imgt-chip.imgt-saving {
    background: #E9F8F1;
    border-color: #BFEBD8;
}
.as-imgtool .imgt-chip.imgt-saving strong { color: var(--as-success, #16A06A); }
.as-imgtool .imgt-chip.imgt-saving.is-worse {
    background: #FDEEF1;
    border-color: #F6CBD4;
}
.as-imgtool .imgt-chip.imgt-saving.is-worse strong { color: var(--as-error, #E0405A); }

/* Stato "sto convertendo" */
.as-imgtool .imgt-status {
    text-align: center;
    font-size: 13.5px;
    color: var(--as-text-soft, #5D5B6B);
    min-height: 20px;
    padding: 4px 20px 0;
}
.as-imgtool .imgt-status.is-error { color: var(--as-error, #E0405A); font-weight: 600; }

/* ---------------------------------------------------------
   4) SLIDER COMPRESSIONE — piu' alto = meno KB
   --------------------------------------------------------- */
.as-imgtool .imgt-slider-row {
    padding: 14px 26px 6px;
}
.as-imgtool .imgt-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--as-text, #14131A);
    margin-bottom: 8px;
}
.as-imgtool .imgt-slider-label span {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--as-primary, #5B54F0);
    background: var(--as-primary-soft, #ECEAFF);
    border-radius: 8px;
    padding: 2px 10px;
}
.as-imgtool input[type="range"].imgt-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--as-primary, #5B54F0) 0%, var(--as-primary, #5B54F0) var(--fill, 25%), #E7E5F2 var(--fill, 25%), #E7E5F2 100%);
    outline: none;
    cursor: pointer;
    margin: 0;
}
.as-imgtool input[type="range"].imgt-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--as-primary, #5B54F0);
    box-shadow: 0 2px 8px rgba(91, 84, 240, 0.35);
    cursor: grab;
    transition: transform 0.12s ease;
}
.as-imgtool input[type="range"].imgt-range::-webkit-slider-thumb:hover { transform: scale(1.1); }
.as-imgtool input[type="range"].imgt-range::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--as-primary, #5B54F0);
    box-shadow: 0 2px 8px rgba(91, 84, 240, 0.35);
    cursor: grab;
}
.as-imgtool .imgt-slider-hint {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #A6A2B8;
    margin-top: 6px;
}

/* ---------------------------------------------------------
   4b) SELETTORE COLORE SFONDO
   Solo per le conversioni verso JPEG: il JPEG non ha canale
   alpha, quindi la trasparenza va riempita con un colore.
   --------------------------------------------------------- */
.as-imgtool .imgt-bg-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 26px 2px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--as-text, #14131A);
}
.as-imgtool .imgt-bg-row input[type="color"] {
    width: 46px;
    height: 34px;
    border: 1.5px solid var(--as-border, #E3E1EE);
    border-radius: 10px;
    padding: 2px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease;
}
.as-imgtool .imgt-bg-row input[type="color"]:hover {
    border-color: var(--as-primary-2, #7D70F7);
}
.as-imgtool .imgt-bg-note {
    font-weight: 400;
    font-size: 12.5px;
    color: var(--as-text-soft, #5D5B6B);
}

/* ---------------------------------------------------------
   4c) CAMPI NUMERICI E SELECT (ridimensiona, comprimi a KB)
   --------------------------------------------------------- */
.as-imgtool .imgt-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 14px;
    padding: 16px 26px 2px;
}
.as-imgtool .imgt-field { display: flex; flex-direction: column; gap: 6px; }
.as-imgtool .imgt-field label {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--as-text-soft, #5D5B6B);
}
.as-imgtool .imgt-field input[type="number"],
.as-imgtool .imgt-field select {
    width: 130px;
    padding: 11px 13px;
    font-size: 15px;
}
.as-imgtool .imgt-lock {
    width: 46px; height: 46px;
    border-radius: 12px;
    border: 1.5px solid var(--as-border, #E3E1EE);
    background: #fff;
    color: var(--as-text-soft, #5D5B6B);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
}
.as-imgtool .imgt-lock svg { width: 20px; height: 20px; }
.as-imgtool .imgt-lock.is-on {
    color: #fff;
    background: var(--as-primary, #5B54F0);
    border-color: var(--as-primary, #5B54F0);
}
.as-imgtool .imgt-check {
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 10px 26px 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    color: var(--as-text, #14131A);
}
.as-imgtool .imgt-check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--as-primary, #5B54F0);
    cursor: pointer;
}

/* ---------------------------------------------------------
   4d) TOOLBAR AZIONI RAPIDE (ruota, capovolgi)
   --------------------------------------------------------- */
.as-imgtool .imgt-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px 2px;
}
.as-imgtool .imgt-tbtn {
    min-width: 48px; height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1.5px solid var(--as-border, #E3E1EE);
    background: #fff;
    color: var(--as-primary, #5B54F0);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}
.as-imgtool .imgt-tbtn svg { width: 20px; height: 20px; }
.as-imgtool .imgt-tbtn:hover {
    background: var(--as-primary-soft, #ECEAFF);
    border-color: var(--as-primary-2, #7D70F7);
}

/* ---------------------------------------------------------
   4e) RIQUADRO DI RITAGLIO INTERATTIVO
   --------------------------------------------------------- */
.as-imgtool .imgt-crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    line-height: 0;
}
.as-imgtool .imgt-crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 420px;
    border-radius: 8px;
}
.as-imgtool .imgt-crop-box {
    position: absolute;
    border: 2px solid var(--as-primary, #5B54F0);
    box-shadow: 0 0 0 9999px rgba(20, 19, 26, 0.45);
    cursor: move;
    border-radius: 2px;
}
.as-imgtool .imgt-crop-h {
    position: absolute;
    width: 16px; height: 16px;
    background: #fff;
    border: 2.5px solid var(--as-primary, #5B54F0);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(20, 19, 26, 0.25);
}
.as-imgtool .imgt-crop-h.h-nw { top: -9px; left: -9px; cursor: nwse-resize; }
.as-imgtool .imgt-crop-h.h-ne { top: -9px; right: -9px; cursor: nesw-resize; }
.as-imgtool .imgt-crop-h.h-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.as-imgtool .imgt-crop-h.h-se { bottom: -9px; right: -9px; cursor: nwse-resize; }

/* Nota informativa sotto i controlli */
.as-imgtool .imgt-note {
    font-size: 12.5px;
    color: var(--as-text-soft, #5D5B6B);
    text-align: center;
    padding: 8px 24px 0;
}

/* ---------------------------------------------------------
   5) AZIONI — download + nuova immagine
   --------------------------------------------------------- */
.as-imgtool .imgt-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px 24px;
}
.as-imgtool .imgt-btn-ghost {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--as-primary, #5B54F0);
    background: #fff;
    border: 1.5px solid var(--as-border, #E3E1EE);
    border-radius: 14px;
    padding: 13px 26px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.as-imgtool .imgt-btn-ghost:hover {
    border-color: var(--as-primary-2, #7D70F7);
    background: var(--as-primary-soft, #ECEAFF);
}

/* ---------------------------------------------------------
   6) RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 600px) {
    .as-imgtool .imgt-drop { padding: 34px 16px; }
    .as-imgtool .imgt-result { gap: 10px; }
    .as-imgtool .imgt-chip { min-width: 108px; padding: 8px 12px; }
    .as-imgtool .imgt-slider-row { padding: 12px 18px 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .as-imgtool * { transition: none !important; }
}
