/* ==========================================================================
   App Download – variante FLOTTANTE (opzione del widget Sitefinity)
   Vanilla CSS, flexbox. Si affianca a app-download.css (variante in pagina).

   Stati (data-state sul root .app-fl):
     collapsed  barra compatta: icona + "Scarica l'app"
     expanded   pannello: card 360 px (≥ 768 px) o pannello dal basso (< 768 px)
   Piattaforma (data-platform): ios | android | desktop
     il QR compare solo su desktop.
   ========================================================================== */

.app-fl {
  --app-fl-navy: #162B48;
  --app-fl-text-2: #444C60;
  --app-fl-label: #005D5D;
  --app-fl-line: #E8E9EB;
  --app-fl-surface: #F5F8FB;
  --app-fl-offset: 24px;
  --app-fl-shadow: 0 10px 15px rgba(0, 0, 0, .12);
  --app-fl-shadow-xl: 0 20px 25px rgba(0, 0, 0, .15);

  position: fixed;
  right: var(--app-fl-offset);
  bottom: max(var(--app-fl-offset), env(safe-area-inset-bottom));
  /* Sotto la navbar sticky (2000), gli skip link (9999) e i banner cookie (di norma ≥ 1000) */
  z-index: var(--app-fl-z, 900);
  max-width: calc(100vw - 2 * var(--app-fl-offset));
  font-family: Poppins, sans-serif;
  color: var(--app-fl-navy);
  transition: opacity 200ms ease-in-out, visibility 200ms;
}
.app-fl *, .app-fl *::before, .app-fl *::after { box-sizing: border-box; }
.app-fl[hidden] { display: none; }
.app-fl[data-side="left"] { right: auto; left: var(--app-fl-offset); }

/* Nascosto mentre il widget in pagina o il footer sono visibili */
.app-fl.is-suppressed { opacity: 0; visibility: hidden; }

/* Testi: specificità sufficiente a battere gli stili globali del sito (p, h*) */
.app-fl .app-fl__text { margin: 0; color: inherit; }

/* --- Barra compatta ------------------------------------------------------- */
.app-fl__bar {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--app-fl-shadow);
  padding: 6px;
}
.app-fl[data-state="expanded"] .app-fl__bar { display: none; }

.app-fl__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--app-fl-navy);
  font: 600 .9375rem/1.2 Poppins, sans-serif;
  text-align: left;
  cursor: pointer;
}
.app-fl__toggle-icon { width: 44px; height: 44px; border-radius: 10px; display: block; flex-shrink: 0; }
.app-fl__toggle-name { display: none; }
.app-fl__qr-glyph { display: none; }
.app-fl__chevron { width: 20px; height: 20px; flex-shrink: 0; }

.app-fl__iconbtn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--app-fl-text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.app-fl__iconbtn:hover { background: var(--app-fl-surface); color: var(--app-fl-navy); }
.app-fl__iconbtn svg { width: 20px; height: 20px; }

/* --- Pannello aperto ------------------------------------------------------ */
.app-fl__panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 360px;
  max-width: 100%;
  max-height: calc(100vh - 2 * var(--app-fl-offset));
  max-height: calc(100dvh - 2 * var(--app-fl-offset));
  overflow-y: auto;
  padding: 24px;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--app-fl-shadow-xl);
}
.app-fl__panel[hidden] { display: none; }

.app-fl__handle { display: none; }

.app-fl__head { display: flex; align-items: center; gap: 12px; }
.app-fl__icon { width: 48px; height: 48px; border-radius: 12px; display: block; flex-shrink: 0; }
.app-fl__titles { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-fl .app-fl__label { font-size: .75rem; font-weight: 600; color: var(--app-fl-label); }
.app-fl .app-fl__title { font-size: 1.25rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.app-fl .app-fl__desc { font-size: .875rem; line-height: 1.5; color: var(--app-fl-text-2); }

/* QR: solo desktop */
.app-fl__qr {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--app-fl-surface);
  border-radius: 16px;
}
.app-fl[data-platform="desktop"] .app-fl__qr { display: flex; }
.app-fl__qr-code { background: #fff; padding: 10px; border-radius: 10px; line-height: 0; flex-shrink: 0; }
.app-fl__qr-code svg { width: 104px; height: 104px; display: block; }
.app-fl__qr-texts { display: flex; flex-direction: column; gap: 6px; }
.app-fl .app-fl__qr-title { font-size: .9375rem; line-height: 1.35; font-weight: 600; }
.app-fl .app-fl__qr-hint { font-size: .8125rem; line-height: 1.45; color: var(--app-fl-text-2); }

/* Badge ufficiali: nessuno sfondo, dimensione per altezza */
.app-fl__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.app-fl__store { display: block; flex: none; line-height: 0; border-radius: 8px; text-decoration: none; }
.app-fl__badge { display: block; height: 40px; width: auto; max-width: none; }
/* Lo store del dispositivo va per primo */
.app-fl[data-platform="android"] .app-fl__store--android { order: -1; }

/* --- Desktop / tablet: barra con nome dell'app e glifo QR ---------------- */
@media (min-width: 768px) {
  .app-fl__toggle-icon { width: 40px; height: 40px; }
  .app-fl__toggle-name { display: inline; }
  .app-fl[data-platform="desktop"] .app-fl__qr-glyph { display: block; width: 20px; height: 20px; }
}

/* --- Mobile: pannello che sale dal basso --------------------------------- */
@media (max-width: 767px) {
  .app-fl { --app-fl-offset: 16px; }
  .app-fl__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    padding: 12px 24px calc(28px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .14);
  }
  .app-fl__handle {
    display: block;
    align-self: center;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #D0D2D7;
  }
  .app-fl__icon { width: 56px; height: 56px; border-radius: 14px; }
  .app-fl .app-fl__title { font-size: 1.375rem; }
  .app-fl .app-fl__desc { font-size: .9375rem; line-height: 1.55; }
  .app-fl__badge { height: 48px; }
}

/* --- Focus (stesso anello del widget in pagina) -------------------------- */
.app-fl :focus-visible {
  outline: 3px solid var(--app-fl-navy);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px #fff;
}
/* Il mixin globale fluo-focus impone con !important un outline fluo che sul bianco
   non arriva a 3:1: un anello navy interno, disegnato con ::after, garantisce il contrasto
   senza ricorrere a !important */
.app-fl__toggle,
.app-fl__iconbtn,
.app-fl__store { position: relative; }
.app-fl .app-fl__store:focus-visible { border-radius: 8px; }
.app-fl__toggle:focus-visible::after,
.app-fl__iconbtn:focus-visible::after,
.app-fl__store:focus-visible::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid var(--app-fl-navy);
  border-radius: inherit;
  pointer-events: none;
}

.app-fl__sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .app-fl { transition: none; }
}
@media print {
  .app-fl { display: none !important; }
}
