/* ==========================================================================
   Opscadia — chatbot widget (floating, iniettato da Assets/js/chatbot.js)
   Tema scuro/viola coerente con styles.css. Tasti sempre pill (9999px).
   ========================================================================== */

#opscadia-chatbot-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

#opscadia-chatbot-launcher:hover {
  transform: scale(1.08);
  opacity: 0.85;
}

#opscadia-chatbot-launcher.opscadia-chatbot-hidden {
  display: none;
}

#opscadia-chatbot-launcher svg {
  width: 34px;
  height: 34px;
}

#opscadia-chatbot-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 140px));
  background: #ffffff;
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#opscadia-chatbot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.opscadia-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-bottom: 1px solid rgba(124, 58, 237, 0.12);
}

.opscadia-chatbot-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.opscadia-chatbot-brand img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  object-fit: contain;
}

.opscadia-chatbot-header strong {
  color: #1e1b4b;
  font-size: 15px;
}

.opscadia-chatbot-header span {
  display: block;
  color: #6d28d9;
  font-size: 12px;
  margin-top: 2px;
}

.opscadia-chatbot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#opscadia-chatbot-new {
  background: none;
  border: none;
  cursor: pointer;
  color: #7c3aed;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.2s ease, transform 0.2s ease;
}

#opscadia-chatbot-new svg {
  width: 17px;
  height: 17px;
}

#opscadia-chatbot-new:hover {
  color: #5b21b6;
  transform: scale(1.12);
}

#opscadia-chatbot-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #7c3aed;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

#opscadia-chatbot-close:hover {
  transform: rotate(90deg);
}

#opscadia-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.opscadia-chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.opscadia-chatbot-msg.user {
  align-self: flex-end;
  background: #5b21b6;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.opscadia-chatbot-msg.bot {
  align-self: flex-start;
  background: #f5f3ff;
  color: #1e1b4b;
  border: 1px solid rgba(124, 58, 237, 0.12);
  border-bottom-left-radius: 4px;
}

.opscadia-chatbot-msg.error {
  align-self: flex-start;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.opscadia-chatbot-msg.typing {
  align-self: flex-start;
  background: #f5f3ff;
  border: 1px solid rgba(124, 58, 237, 0.12);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.opscadia-chatbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #8b5cf6;
  animation: opscadia-chatbot-bounce 1.2s infinite ease-in-out;
}

.opscadia-chatbot-dot:nth-child(2) { animation-delay: 0.15s; }
.opscadia-chatbot-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes opscadia-chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

#opscadia-chatbot-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(124, 58, 237, 0.12);
  background: #fff;
}

#opscadia-chatbot-input {
  flex: 1;
  background: #f9fafb;
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 9999px;
  padding: 10px 16px;
  color: #1e1b4b;
  font-size: 13.5px;
  outline: none;
}

#opscadia-chatbot-input::placeholder {
  color: #9ca3af;
}

#opscadia-chatbot-input:focus {
  border-color: #7c3aed;
}

#opscadia-chatbot-send {
  background: none;
  border: none;
  color: #7c3aed;
  border-radius: 9999px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

#opscadia-chatbot-send:hover {
  opacity: 0.75;
}

#opscadia-chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#opscadia-chatbot-send svg {
  width: 22px;
  height: 22px;
  fill: #7c3aed;
}

@media (max-width: 480px) {
  #opscadia-chatbot-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 92px;
  }
}
