/* ==== Chat IA Widget ==== */
#ai-chat-root, #ai-chat-root * { box-sizing: border-box; }

#ai-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
  transition: transform .2s ease, box-shadow .2s ease;
}
#ai-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(37,99,235,.45); }
#ai-chat-fab svg { width: 28px; height: 28px; }
#ai-chat-fab .ai-chat-badge {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  font-family: system-ui, sans-serif;
}

#ai-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 94px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15,23,42,.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  animation: aiChatIn .2s ease;
}
#ai-chat-panel.open { display: flex; }

@keyframes aiChatIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#ai-chat-header {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
#ai-chat-header .ai-chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
}
#ai-chat-header .ai-chat-avatar svg { width: 20px; height: 20px; }
#ai-chat-header .ai-chat-title { flex: 1; }
#ai-chat-header .ai-chat-title strong { display: block; font-size: 15px; }
#ai-chat-header .ai-chat-title small { font-size: 11px; opacity: .85; }
#ai-chat-header button {
  background: transparent; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1; padding: 4px 8px;
}

#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  display: flex; flex-direction: column; gap: 10px;
}
.ai-chat-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-chat-msg.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.ai-chat-msg a { color: inherit; text-decoration: underline; }
.ai-chat-msg.bot a { color: #2563eb; font-weight: 600; }

.ai-chat-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex; gap: 4px;
}
.ai-chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #94a3b8;
  animation: aiTyping 1.2s infinite ease-in-out;
}
.ai-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ai-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aiTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

#ai-chat-suggestions {
  padding: 0 14px 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
  background: #f8fafc;
}
#ai-chat-suggestions button {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
#ai-chat-suggestions button:hover { background: #2563eb; color: #fff; border-color: #2563eb; }

#ai-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
#ai-chat-form input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
#ai-chat-form input:focus { border-color: #2563eb; }
#ai-chat-form button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#ai-chat-form button:disabled { opacity: .5; cursor: not-allowed; }
#ai-chat-form button svg { width: 18px; height: 18px; }

#ai-chat-footer {
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  padding: 4px 0 6px;
  background: #fff;
}

@media (max-width: 480px) {
  #ai-chat-panel {
    right: 8px; left: 8px; bottom: 84px;
    width: auto; height: calc(100vh - 110px);
  }
  #ai-chat-fab { right: 14px; bottom: 14px; width: 56px; height: 56px; }
}
