/* ===========================================================
   CHATBOT WIDGET - chatbot.css
   Stili per il widget chatbot flottante
   =========================================================== */

/* --- Bubble flottante --- */
#chatbot-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background-color: #D98C6B;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(217, 140, 107, 0.45);
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
  outline: none;
}

#chatbot-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(217, 140, 107, 0.55);
}

#chatbot-bubble svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
  transition: opacity 0.2s ease;
}

#chatbot-bubble .icon-close {
  display: none;
}

#chatbot-bubble.is-open .icon-chat {
  display: none;
}

#chatbot-bubble.is-open .icon-close {
  display: block;
}

/* --- Badge notifica --- */
#chatbot-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  background-color: #3A3A3A;
  border-radius: 50%;
  border: 2px solid #F9F6F2;
  display: none;
}

#chatbot-badge.visible {
  display: block;
}

/* --- Finestra chat --- */
#chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 130px);
  background-color: #F9F6F2;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#chatbot-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header finestra --- */
#chatbot-header {
  background-color: #3A3A3A;
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#chatbot-header-avatar {
  width: 36px;
  height: 36px;
  background-color: #D98C6B;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.1em;
  color: #ffffff;
  font-weight: 700;
}

#chatbot-header-info {
  flex: 1;
}

#chatbot-header-name {
  font-family: 'Playfair Display', serif;
  font-size: 0.95em;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

#chatbot-header-status {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.72em;
  opacity: 0.8;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

#chatbot-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background-color: #6fcf97;
  border-radius: 50%;
  display: inline-block;
}

/* --- Pulsante nuova chat --- */
#chatbot-new-chat-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

#chatbot-new-chat-btn:hover {
  background-color: rgba(255,255,255,0.15);
}

#chatbot-new-chat-btn svg {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

/* --- Link nei messaggi bot --- */
.chatbot-msg.bot a {
  color: #D98C6B;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chatbot-msg.bot a:hover {
  color: #c87a58;
}

/* --- Area messaggi --- */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

#chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background-color: #EAE3DA;
  border-radius: 4px;
}

/* --- Singolo messaggio --- */
.chatbot-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.84em;
  line-height: 1.55;
  word-wrap: break-word;
}

.chatbot-msg.bot {
  background-color: #ffffff;
  color: #3A3A3A;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.chatbot-msg.user {
  background-color: #D98C6B;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* --- Typing indicator --- */
.chatbot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 13px;
  background-color: #ffffff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.chatbot-typing span {
  width: 7px;
  height: 7px;
  background-color: #D98C6B;
  border-radius: 50%;
  animation: chatbot-bounce 1.2s infinite ease-in-out;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Input area --- */
#chatbot-input-area {
  padding: 12px 14px;
  background-color: #F2EEE9;
  border-top: 1px solid #EAE3DA;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  border: 1px solid #EAE3DA;
  border-radius: 20px;
  padding: 9px 14px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.84em;
  background-color: #ffffff;
  color: #3A3A3A;
  resize: none;
  outline: none;
  max-height: 90px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.2s ease;
}

#chatbot-input:focus {
  border-color: #D98C6B;
}

#chatbot-input::placeholder {
  color: #b0a89e;
}

#chatbot-send-btn {
  width: 38px;
  height: 38px;
  background-color: #D98C6B;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.15s ease;
  outline: none;
}

#chatbot-send-btn:hover {
  background-color: #c87a58;
  transform: scale(1.05);
}

#chatbot-send-btn:disabled {
  background-color: #EAE3DA;
  cursor: not-allowed;
  transform: none;
}

#chatbot-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

/* --- Footer disclaimer --- */
#chatbot-footer {
  padding: 6px 14px 8px;
  background-color: #F2EEE9;
  text-align: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.67em;
  color: #b0a89e;
  flex-shrink: 0;
}

/* --- Responsive mobile --- */
@media (max-width: 480px) {
  #chatbot-window {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 90px;
  }

  #chatbot-bubble {
    bottom: 18px;
    right: 18px;
  }
}