/* ═══ MIA CHATBOT WIDGET ═══ */

/* Launcher button */
.mia-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #D0FE9C;
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(208, 254, 156, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.mia-chat-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(208, 254, 156, 0.45);
}
.mia-chat-launcher svg {
  width: 26px;
  height: 26px;
  transition: transform 0.2s;
}
.mia-chat-launcher.open svg.icon-chat { display: none; }
.mia-chat-launcher:not(.open) svg.icon-close { display: none; }

/* Ensure chatbot stays above cookie banners */
.mia-chat-window.visible ~ *,
#iubenda-cs-banner {
  z-index: auto !important;
}

/* Chat window */
.mia-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  border-radius: 16px;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.mia-chat-window.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.mia-chat-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.mia-chat-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D0FE9C;
  flex-shrink: 0;
}
.mia-chat-header-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.mia-chat-header-sub {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-left: auto;
}
.mia-chat-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.mia-chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.mia-chat-close svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Messages area */
.mia-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.mia-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.mia-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.mia-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Message bubbles */
.mia-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.55;
  word-wrap: break-word;
  animation: mia-msg-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes mia-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.mia-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-left-radius: 4px;
}
.mia-msg.user {
  align-self: flex-end;
  background: #D0FE9C;
  color: #0a0a0a;
  border-bottom-right-radius: 4px;
}

/* Links in assistant messages */
.mia-msg.assistant a {
  color: #D0FE9C;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}
.mia-msg.assistant a:hover {
  color: #D9CDFE;
}

/* Suggestion chips */
.mia-chat-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.mia-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 9px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.mia-chip:hover {
  background: rgba(208, 254, 156, 0.08);
  border-color: rgba(208, 254, 156, 0.2);
  color: #D0FE9C;
}

/* Loading dots */
.mia-loading {
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  align-self: flex-start;
}
.mia-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  animation: mia-dot-bounce 1.2s infinite;
}
.mia-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.mia-loading-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes mia-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Error message */
.mia-error {
  align-self: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: mia-msg-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.mia-error-retry {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.2s;
}
.mia-error-retry:hover {
  border-color: #D0FE9C;
  color: #D0FE9C;
}

/* Input area */
.mia-chat-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.mia-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: #fff;
  outline: none;
  resize: none;
  height: 40px;
  max-height: 80px;
  transition: border-color 0.2s;
}
.mia-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}
.mia-chat-input:focus {
  border-color: rgba(208, 254, 156, 0.3);
}
.mia-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: #D0FE9C;
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
.mia-chat-send:disabled {
  opacity: 0.35;
  cursor: default;
}
.mia-chat-send:not(:disabled):hover {
  transform: scale(1.05);
}
.mia-chat-send svg {
  width: 18px;
  height: 18px;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .mia-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .mia-chat-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .mia-chat-input-area {
    padding: 10px 12px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .mia-chat-messages {
    padding: 12px 12px 8px;
  }
  .mia-chat-chips {
    padding: 0 12px 10px;
  }
  .mia-chat-close {
    display: block;
  }
  .mia-chat-launcher {
    bottom: 16px;
    right: 16px;
  }
  .mia-chat-launcher.open {
    display: none;
  }
  /* Prevent body scroll when chat is open */
  body.mia-chat-body-lock {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
}
