/* ============================================================
   GUFETTO — widget assistente AI del sito Agorà
   ============================================================ */
#gufetto-bottone {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #1f3a8a;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  transition: transform .15s ease;
}
#gufetto-bottone:hover { transform: scale(1.06); }
#gufetto-bottone img { width: 34px; height: 34px; object-fit: contain; display: block; }

#gufetto-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #d33;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 5px;
  font-family: sans-serif;
}

#gufetto-pannello {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 130px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.28);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
}
#gufetto-pannello.aperto { display: flex; }

#gufetto-header {
  background: #1f3a8a;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#gufetto-header img { width: 26px; height: 26px; object-fit: contain; }
#gufetto-header .titolo { font-weight: 700; font-size: 15px; flex: 1; }
#gufetto-chiudi {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; opacity: .85;
}
#gufetto-chiudi:hover { opacity: 1; }

#gufetto-messaggi {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F9F7F2;
}
.gufetto-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.gufetto-msg.utente {
  align-self: flex-end;
  background: #1f3a8a;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.gufetto-msg.assistente {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #e3e0d8;
  border-bottom-left-radius: 3px;
}
.gufetto-msg.sistema {
  align-self: center;
  background: transparent;
  color: #888;
  font-size: 12px;
  font-style: italic;
}
.gufetto-typing { align-self: flex-start; display: flex; gap: 3px; padding: 10px 12px; }
.gufetto-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #999;
  animation: gufetto-blink 1.2s infinite ease-in-out;
}
.gufetto-typing span:nth-child(2) { animation-delay: .2s; }
.gufetto-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gufetto-blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

#gufetto-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
}
#gufetto-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
}
#gufetto-input:focus { outline: none; border-color: #1f3a8a; }
#gufetto-invia {
  background: #1f3a8a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
#gufetto-invia:disabled { opacity: .5; cursor: default; }

@media (max-width: 420px) {
  #gufetto-pannello { right: 12px; left: 12px; width: auto; bottom: 84px; }
  #gufetto-bottone { right: 14px; bottom: 14px; }
}
