:root {
  --rchat-color: #34C759;          /* sfondo header + banner + invia */
  --rchat-text-color: #ffffff;     /* colore testo header/banner/bolla/mic */
  --rchat-shadow: 0 6px 18px rgba(0,0,0,.12);
  --rchat-radius: 14px;
  --rchat-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* CONTENITORE FLOTTANTE */
.rchat-floating {
  position: fixed;
  bottom: 28px;
  z-index: 999999;
  font-family: var(--rchat-font);
}
.rchat-floating.bottom-right { right: 0; }
.rchat-floating.bottom-left  { left: 0; }

/* BANNER CHIUSO – ARROTONDATO SOLO A SINISTRA */
.rchat-toggle {
  display: flex;
  align-items: center;
  background: var(--rchat-color);
  color: var(--rchat-text-color);
  border-radius: 46px 0 0 46px;   /* sinistra tonda, destra dritta */
  padding: 12px 22px 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--rchat-shadow);
  cursor: pointer;
  max-width: 420px;
  min-height: 110px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.rchat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.rchat-toggle-avatar {
  flex-shrink: 0;
  margin-right: 12px;
}
.rchat-toggle-avatar img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid #fff;
  object-fit: cover;
  background:#fff;
}
.rchat-toggle-text {
  flex: 1;
  font-size: 18px;                 /* caratteri grandi */
  line-height: 1.3;
}

/* FINESTRA CHAT (desktop) – altezza dinamica */
.rchat-box {
  position: relative;
  display: none;
  width: 410px;
  min-height: 540px;
  height: 70vh;                    /* ~50% in più rispetto a prima */
  max-height: 800px;
  background: #fff;
  border-radius: var(--rchat-radius);
  box-shadow: var(--rchat-shadow);
  overflow: hidden;
  flex-direction: column;
}
.rchat-floating.open .rchat-box {
  display: flex;
}

/* BOLLA DI CHIUSURA – SOSPESA E CENTRATA */
.rchat-close-bubble {
  position: absolute;
  top: -28px;          /* tutta fuori, tipo “luna” sopra la chat */
  right: 16px;
  width: 46px;
  height: 46px;
  background-color: var(--rchat-color);
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: var(--rchat-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;     /* freccia grande */
  color: var(--rchat-text-color);
  z-index: 1000000;
}
.rchat-close-bubble:hover {
  opacity: .9;
}

/* HEAD CHAT – tutta cliccabile per chiudere (JS) */
.rchat-head {
  background: var(--rchat-color);
  color: var(--rchat-text-color);
  font-weight: 600;
  padding: 10px 14px;
  text-align: center;
  font-size: 17px;
  cursor: pointer;     /* indica che è cliccabile */
}

/* Area messaggi */
.rchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #fafafa;
  font-size: 15px;
  line-height: 1.4;
}
.msg { margin: 6px 0; }
.msg.user strong { color: #111; }
.msg.ai strong   { color: var(--rchat-color); }
.msg.ai {
  background: #f0fdf4;
  border-left: 3px solid var(--rchat-color);
  padding: 4px 6px;
  border-radius: 6px;
}

/* Input */
.rchat-input {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #eee;
}
.rchat-input textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-family: var(--rchat-font);
  font-size: 14px;
}
.rchat-input textarea::placeholder {
  color: #666;
  opacity: 1;
}

/* Wrapper microfono + label */
.rchat-mic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* MICROFONO – SVG + label “Audio” */
#rchat-mic {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: all .2s ease;
  border: 1px solid #ccc;
  background-color: var(--rchat-text-color);
  background-image: url('../img/audio-off.svg');
  background-size: 60%;
  background-position: center;
  background-repeat: no-repeat;
}
#rchat-mic:hover {
  opacity: .9;
}
#rchat-mic.rchat-mic-on {
  background-color: var(--rchat-text-color);
  border-color: var(--rchat-color);
  background-image: url('../img/audio-on.svg');
}
.rchat-mic-label {
  font-size: 11px;
  color: #777;
  font-weight: 400;
}

/* Pulsanti (INVIA) */
.rchat-input button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--rchat-font);
}
#rchat-send {
  background: var(--rchat-color);
  color: #fff;
  transition: background .2s;
}
#rchat-send:hover { background: #2db450; }

/* Scrollbar estetica */
.rchat-messages::-webkit-scrollbar {
  width: 8px;
}
.rchat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 8px;
}
.rchat-messages::-webkit-scrollbar-thumb {
  background: var(--rchat-color);
  border-radius: 8px;
}

/* Animazione apertura */
@keyframes rchat-pop {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.rchat-box { animation: rchat-pop .25s ease; }

/* MOBILE: chat quasi fullscreen */
@media (max-width: 600px) {

  .rchat-floating {
    bottom: 0;
    right: 0;
    left: 0;
    display: flex;
    justify-content: flex-end;
  }

  .rchat-toggle {
    max-width: 100%;
    border-radius: 0;         /* su mobile banner dritto, tipo Prometeo */
  }

  .rchat-box {
    width: 100vw;
    height: calc(100vh - 70px);  /* occupa quasi tutto lo schermo sotto il menu */
    border-radius: 0;
  }

  .rchat-close-bubble {
    top: -28px;
    right: 16px;
  }
}
