/* Contenitore flottante */
.caw-float-wrap{
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  z-index: 2147483000; /* sopra tutto */
}

/* Bottone tondo */
.caw-launcher{
  appearance: none; border: 0; cursor: pointer;
  width: 60px; height: 60px; border-radius: 999px;
  background: var(--caw-accent, #2E7D5B); color: #fff;
  box-shadow: 0 14px 30px rgba(0,0,0,.22), inset 0 0 0 1px rgba(255,255,255,.12);
  display: grid; place-items: center;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  z-index: 2147483001; /* SEMPRE sopra al pannello */
}
.caw-launcher:hover{ transform: translateY(-1px) scale(1.02); }
.caw-launcher:active{ transform: translateY(0) scale(.98); }
.caw-launcher:focus-visible{ outline: 3px solid rgba(46,125,91,.35); outline-offset: 3px; }

.caw-icon{ width: 26px; height: 26px; display:block; }
.caw-icon-close{ display:none; }
/* quando aria-expanded=true, mostra X e nascondi chat */
.caw-launcher[aria-expanded="true"] .caw-icon-chat{ display:none; }
.caw-launcher[aria-expanded="true"] .caw-icon-close{ display:block; }

/* Pannello chat */
.caw-panel{
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  width: 380px; height: 620px; max-height: calc(100vh - 140px);
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
  z-index: 2147483000;
  transition: opacity .18s ease, transform .18s ease;
  transform: translateY(8px); opacity: 0;
}
.caw-open .caw-panel{ transform: translateY(0); opacity: 1; }

/* Pulsante X interno al pannello */
.caw-close{
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  color: #222; display: grid; place-items: center;
  cursor: pointer; z-index: 2;
}
.caw-close svg{ width: 18px; height: 18px; }

/* Mobile: pannello quasi fullscreen;
   QUANDO APERTA sposta il bottone in ALTO A SINISTRA (lontano dalla chat history di Safari) */
@media (max-width: 640px){
  .caw-panel{
    left: 10px; right: 10px;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    width: auto; height: auto; border-radius: 14px; max-height: none;
  }
  .caw-launcher{ width: 58px; height: 58px; }

  /* spostamento del bottone quando la chat è aperta */
  .caw-open .caw-launcher{
    position: fixed !important;
    left: 12px;           /* <<— A SINISTRA */
    right: auto;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    bottom: auto;
  }
  .caw-close{
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: 8px;
  }
}

/* Shortcode embed */
.caw-embed{ border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background:#fff; }

/* Disabilita completamente la X interna al pannello (desktop e mobile) */
.caw-close { 
  display: none !important;
}
