/* --- RESET BASE E FONT --- */
#we-chat * {
  box-sizing: border-box;
}

#we-chat {
  /* --- Stili Popup --- */
  position: fixed;
  bottom: 100px; /* Distanza dal basso (sopra la bolla) */
  left: 20px; /* <--- MODIFICATO (da right a left) */
  width: 400px; /* Larghezza fissa */
  max-width: 90vw; /* Limite su mobile */
  height: 600px; /* Altezza fissa */
  max-height: 80vh; /* Limite su mobile */
  z-index: 9998;

  /* --- Stili Grafici Esistenti --- */
  background: #1d1d1d;
  color: #fff;
  border-radius: 12px;
  padding: 0; 
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* --- Animazione Entrata/Uscita --- */
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  transform: translateY(20px);
  opacity: 0;
}

/* Stato Nascosto (gestito da JS) */
#we-chat.we-chat-hidden {
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none; /* Non cliccabile se nascosto */
}

/* Stato Visibile (quando .we-chat-hidden viene rimosso) */
#we-chat:not(.we-chat-hidden) {
  transform: translateY(0);
  opacity: 1;
}


/* --- BOLLA DI AVVIO (IL "PULSANTE") --- */
#we-chat-bubble {
  position: fixed;
  bottom: 20px;
  left: 20px; /* <--- MODIFICATO (da right a left) */
  width: 60px;
  height: 60px;
  background: #823D89; /* Colore principale */
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  transition: transform 0.2s ease, filter 0.2s ease;
}

#we-chat-bubble:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}

/* --- HEADER CHATBOT --- */
#chat-header {
  background: #3a3a3a;
  color: #fff;
  padding: 12px 15px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #111;
  flex-shrink: 0; 
}

#we-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 5px;
  opacity: 0.7;
}
#we-chat-close:hover {
  opacity: 1;
}


/* --- AREA MESSAGGI (OUTPUT) --- */
#chat-output {
  flex: 1; 
  overflow-y: auto;
  background: #222;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px; 
}

/* Styling scrollbar */
#chat-output::-webkit-scrollbar { width: 6px; }
#chat-output::-webkit-scrollbar-track { background: #222; }
#chat-output::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }

/* --- BOLLE MESSAGGI --- */
.user-msg, .bot-msg {
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 75%;
  line-height: 1.4;
  word-wrap: break-word;
  color: #f1f1f1;
}

/* Stile per grassetto e corsivo (dal Markdown) */
.bot-msg strong {
  color: #fff; 
  font-weight: 600;
}
.bot-msg em {
  font-style: italic;
}


.user-msg {
  align-self: flex-end;
  background: #823D89;
  color: #fff;
  border-bottom-right-radius: 4px; 
}

.bot-msg {
  align-self: flex-start;
  background: #3a3a3a;
  border-bottom-left-radius: 4px;
}

/* --- AREA INPUT --- */
#chat-input-area {
  display: flex;
  align-items: flex-end;
  padding: 12px;
  background: #1d1d1d;
  border-top: 1px solid #3a3a3a;
  flex-shrink: 0; 
}

#chat-input {
  flex: 1;
  border-radius: 20px;
  padding: 10px 15px;
  border: 1px solid #3a3a3a;
  background: #111;
  color: #fff;
  resize: none;
  font-family: inherit;
  font-size: 14px; /* <--- Questo va bene per desktop */
  line-height: 1.4;
  max-height: 100px;
  overflow-y: hidden;
}

#chat-input:focus {
  outline: none;
  border-color: #823D89;
  box-shadow: 0 0 0 2px rgba(130, 61, 137, 0.5);
}

/* --- PULSANTE INVIO --- */
#chat-send {
  background: #823D89;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.2s ease;
  flex-shrink: 0;
}

#chat-send:hover {
  filter: brightness(1.2);
}

/* --- MEDIA QUERY PER MOBILE --- */
@media (max-width: 480px) {

  #we-chat {
    width: 95vw; 
    max-width: 95vw; 
    left: 2.5vw; 
    right: 2.5vw;
    bottom: 80px; 
    max-height: 75vh; 
  }

  #we-chat-bubble {
    left: 15px;
    bottom: 15px;
    width: 50px;  
    height: 50px; 
  }

  /* --- FIX ZOOM iPHONE --- */
  #chat-input {
    font-size: 16px; /* Impedisce lo zoom automatico su iOS */
  }
}
/* --- Indicatore di digitazione animato (V 3.8.1) --- */
.bot-msg.typing-indicator {
  background: #3a3a3a; /* Stesso colore dei messaggi bot */
  display: flex;
  align-items: center;
  padding: 12px 14px; 
}

.bot-msg.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.4s infinite both;
}

.bot-msg.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.bot-msg.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* --- Stile per le liste (V 3.8.1) --- */
.bot-msg ul {
  padding-left: 20px;
  margin-top: 5px;
  margin-bottom: 5px;
}

.bot-msg li {
  margin-bottom: 4px;
}
/*
 * Stile per i link nel messaggio del bot
 */
#chat-output .bot-msg a {
    color: #ffffff; /* Un blu chiaro, ben visibile sul nero */
    text-decoration: underline; /* Sottolinea sempre i link */
}

#chat-output .bot-msg a:hover {
    color: #ffffff; /* Bianco al passaggio del mouse */
}