/* Flexia AI Chatbot Widget */
:root {
  --fai-c: #7B5EEA;
  --fai-c2: #5B3FCA;
  --fai-radius: 18px;
}

#flexia-chat-btn {
  position: fixed;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--fai-c);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(123,94,234,0.45);
  z-index: 99999;
  transition: transform 0.2s, box-shadow 0.2s;
  bottom: 24px;
}
#flexia-chat-btn:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(123,94,234,0.55); }
#flexia-chat-btn svg { width: 26px; height: 26px; fill: white; }
#flexia-chat-btn.right { right: 24px; }
#flexia-chat-btn.left  { left: 24px; }

#flexia-chat-box {
  position: fixed;
  width: 360px;
  height: 500px;
  background: white;
  border-radius: var(--fai-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  display: flex; flex-direction: column;
  z-index: 99998;
  bottom: 96px;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
#flexia-chat-box.right { right: 24px; }
#flexia-chat-box.left  { left: 24px; }
#flexia-chat-box.open  { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

.fai-chat-header {
  padding: 16px 20px;
  background: var(--fai-c);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.fai-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.fai-chat-title { color: white; font-weight: 600; font-size: 15px; line-height: 1.2; }
.fai-chat-subtitle { color: rgba(255,255,255,0.7); font-size: 12px; }
.fai-chat-close {
  margin-left: auto; background: rgba(255,255,255,0.15); border: none;
  color: white; width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.fai-chat-close:hover { background: rgba(255,255,255,0.3); }

.fai-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.fai-chat-messages::-webkit-scrollbar { width: 4px; }
.fai-chat-messages::-webkit-scrollbar-thumb { background: #E0DCFF; border-radius: 4px; }

.fai-msg {
  max-width: 80%; padding: 10px 14px;
  border-radius: 16px; font-size: 14px; line-height: 1.5;
  animation: fai-pop 0.25s ease;
}
@keyframes fai-pop { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.fai-msg.bot  { background: #F4F2FF; color: #1C1C2E; border-bottom-left-radius: 4px; align-self: flex-start; }
.fai-msg.user { background: var(--fai-c); color: white; border-bottom-right-radius: 4px; align-self: flex-end; }
.fai-msg.typing { opacity: 0.6; font-style: italic; }

.fai-chat-input-row {
  padding: 12px 16px;
  border-top: 1px solid #F0EDFF;
  display: flex; gap: 10px; align-items: center;
  flex-shrink: 0;
}
#flexia-chat-input {
  flex: 1; border: 1.5px solid #E8E4FF; border-radius: 24px;
  padding: 10px 16px; font-size: 14px; outline: none;
  transition: border-color 0.2s; font-family: inherit;
  direction: rtl;
}
#flexia-chat-input:focus { border-color: var(--fai-c); }
#flexia-chat-send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--fai-c); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s; flex-shrink: 0;
}
#flexia-chat-send:hover { background: var(--fai-c2); transform: scale(1.05); }
#flexia-chat-send svg { width: 18px; height: 18px; fill: white; }

@media (max-width: 400px) {
  #flexia-chat-box { width: calc(100vw - 32px); right: 16px !important; left: 16px !important; }
}
