/*
 * Advanced Offers by Clivo — aspetto dell'avviso e della riga nel carrello.
 *
 * La forma è tutta qui, dal primo disegno: l'avviso è un riquadro in basso a sinistra sul computer e una barra sottile
 * in basso sul telefono (sotto i 768 px di finestra, perché è fissato alla finestra). La riga nel carrello si dispone
 * secondo lo spazio della sua colonna (container query). Il JavaScript aggiunge solo le classi di apertura.
 * Il colore dell'offerta arriva dal pannello nella variabile --aoff-accent.
 */

.aoff-avviso,
.aoff-carrello {
  --aoff-accent: #FA5236;
  --aoff-testo: #1d2330;
  --aoff-sfumato: #5f6673;
  --aoff-bordo: #e4e6eb;
  --aoff-raggio: 14px;
  box-sizing: border-box;
  color: var(--aoff-testo);
  font-size: 14px;
  line-height: 1.45;
}
.aoff-avviso *,
.aoff-carrello * { box-sizing: border-box; }
.aoff-avviso [hidden],
.aoff-carrello [hidden] { display: none !important; }

.aoff-nascosto {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.aoff-trappola { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ------------------------------------------------------------------ */
/* Modulo (campo + pulsante), comune ai due punti                      */
/* ------------------------------------------------------------------ */

.aoff-modulo { margin: 0; }
.aoff-modulo__riga { display: flex; gap: 8px; align-items: stretch; }
.aoff-modulo__campo { position: relative; flex: 1 1 auto; min-width: 0; }
.aoff-modulo__input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #cfd3da;
  border-radius: 10px;
  background: #fff;
  color: var(--aoff-testo);
  font: inherit;
  font-size: 15px;
}
.aoff-modulo__input:focus { outline: 2px solid var(--aoff-accent); outline-offset: 1px; border-color: transparent; }
.aoff-modulo__input[aria-invalid="true"] { border-color: #c62828; }
.aoff-modulo__bottone {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--aoff-accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.aoff-modulo__bottone:hover { filter: brightness(.94); }
.aoff-modulo__bottone:focus-visible { outline: 2px solid var(--aoff-testo); outline-offset: 2px; }
.aoff-modulo__bottone[disabled] { opacity: .7; cursor: default; }
.aoff-modulo__gdpr { margin-top: 8px; font-size: 12px; color: var(--aoff-sfumato); }
.aoff-modulo__gdpr label { font-size: 12px; font-weight: 400; }

/* Il fumetto dell'errore: poche parole, sopra il campo sbagliato. */
.aoff-fumetto {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 8px);
  z-index: 2;
  max-width: 260px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: #b3261e;
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.aoff-fumetto::after {
  content: "";
  position: absolute;
  left: 16px; top: 100%;
  border: 6px solid transparent;
  border-top-color: #b3261e;
}
.aoff-fumetto--sotto { position: static; display: inline-block; margin-top: 8px; }
.aoff-fumetto--sotto::after { display: none; }

.aoff-esito {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  font-weight: 600;
  color: #1b5e20;
}
.aoff-esito svg { flex: 0 0 22px; width: 22px; height: 22px; }

/* ------------------------------------------------------------------ */
/* Avviso: computer                                                    */
/* ------------------------------------------------------------------ */

.aoff-avviso {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 1040;
  width: 360px;
  max-width: calc(100vw - 48px);
  border-radius: var(--aoff-raggio);
  background: #fff;
  box-shadow: 0 18px 50px rgba(17, 24, 39, .22), 0 2px 6px rgba(17, 24, 39, .08);
  border-top: 4px solid var(--aoff-accent);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .35s ease, transform .35s ease;
}
.aoff-avviso.is-open { opacity: 1; transform: none; }
.aoff-avviso__barra { display: none; }
.aoff-avviso__corpo { padding: 20px 22px 22px; }
.aoff-avviso__chiudi {
  position: absolute;
  top: 8px; right: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--aoff-sfumato);
  cursor: pointer;
}
.aoff-avviso__chiudi:hover { background: #f1f2f4; color: var(--aoff-testo); }
.aoff-avviso__chiudi svg { width: 18px; height: 18px; }
.aoff-avviso__tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--aoff-accent) 12%, #fff);
  color: color-mix(in srgb, var(--aoff-accent) 75%, #000);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.aoff-avviso__titolo {
  margin: 0 36px 4px 0;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--aoff-testo);
}
.aoff-avviso__testo { margin: 0 0 14px; color: var(--aoff-sfumato); }
.aoff-avviso .aoff-esito { margin-top: 4px; }

/* ------------------------------------------------------------------ */
/* Avviso: telefono (barra in basso che si apre al tocco)              */
/* ------------------------------------------------------------------ */

@media (max-width: 767.98px) {
  .aoff-avviso {
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-width: none;
    border-radius: var(--aoff-raggio) var(--aoff-raggio) 0 0;
    border-top-width: 3px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .aoff-avviso__barra {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    padding: 8px 52px 8px 14px;
    border: 0;
    background: transparent;
    color: var(--aoff-testo);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .aoff-avviso__segno {
    flex: 0 0 32px;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--aoff-accent);
    color: #fff;
    font-weight: 800;
  }
  .aoff-avviso__barra-testo { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
  .aoff-avviso__barra-testo strong { font-size: 15px; font-weight: 800; }
  .aoff-avviso__barra-testo small { font-size: 12px; color: var(--aoff-sfumato); }
  .aoff-avviso__barra-invito {
    flex: 0 0 auto;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--aoff-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
  }
  .aoff-avviso__chiudi { top: 9px; right: 6px; }
  .aoff-avviso__corpo { display: none; padding: 4px 16px 18px; }
  .aoff-avviso.is-expanded .aoff-avviso__corpo { display: block; }
  .aoff-avviso.is-expanded .aoff-avviso__barra-invito { display: none; }
  .aoff-avviso.is-expanded .aoff-avviso__tag { display: none; }
  .aoff-avviso__titolo { font-size: 18px; margin-right: 0; }
  .aoff-avviso.is-expanded .aoff-avviso__titolo { display: none; }
  .aoff-avviso__testo { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .aoff-avviso { transition: none; }
}

/* ------------------------------------------------------------------ */
/* Riga nel carrello                                                   */
/* ------------------------------------------------------------------ */

.aoff-carrello {
  container-type: inline-size;
  margin: 16px 0;
  border: 1px solid color-mix(in srgb, var(--aoff-accent) 35%, #fff);
  border-radius: var(--aoff-raggio);
  background: color-mix(in srgb, var(--aoff-accent) 6%, #fff);
}
.aoff-carrello__dentro {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px 14px;
  align-items: center;
  padding: 16px 18px;
}
.aoff-carrello__segno {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--aoff-accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}
.aoff-carrello__titolo { margin: 0; font-size: 16px; font-weight: 800; color: var(--aoff-testo); }
.aoff-carrello__testo { margin: 2px 0 0; color: var(--aoff-sfumato); }
.aoff-carrello__tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff;
  color: color-mix(in srgb, var(--aoff-accent) 75%, #000);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.aoff-carrello__codice {
  display: inline-block;
  padding: 2px 10px;
  border: 1px dashed var(--aoff-accent);
  border-radius: 6px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--aoff-testo);
}
.aoff-carrello__modulo,
.aoff-carrello .aoff-esito { grid-column: 1 / -1; }

/* Con spazio (colonna del carrello sul computer): testi a sinistra, modulo a destra sulla stessa riga. */
@container (min-width: 620px) {
  .aoff-carrello__dentro { grid-template-columns: 44px minmax(0, 1fr) minmax(280px, 340px); }
  .aoff-carrello__modulo { grid-column: auto; }
  .aoff-carrello .aoff-esito { grid-column: 2 / -1; }
}
@container (max-width: 380px) {
  .aoff-carrello__dentro { grid-template-columns: 1fr; padding: 14px; }
  .aoff-carrello__segno { display: none; }
  .aoff-carrello .aoff-modulo__riga { flex-direction: column; }
  .aoff-carrello .aoff-modulo__bottone { width: 100%; }
}
