/* === Chat Widget === */
.chat-fab {
  position: fixed; bottom: 32px; right: 32px; z-index: 999;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 4px 20px rgba(37,99,235,0.4);
  transition: all 0.3s; display: flex; align-items: center; justify-content: center;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37,99,235,0.5); }
.chat-fib.hidden { display: none; }

.chat-window {
  position: fixed; bottom: 104px; right: 32px; z-index: 998;
  width: 400px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 140px);
  background: #fff; border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15); border: 1px solid #e2e8f0;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(20px) scale(0.95); opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none;
}
.chat-window.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

.chat-header {
  padding: 16px 20px; background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 600;
}
.chat-header-name { font-weight: 600; font-size: 0.95rem; }
.chat-header-status { font-size: 0.75rem; opacity: 0.85; }
.chat-close {
  background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer;
  opacity: 0.8; transition: opacity 0.2s; padding: 4px;
}
.chat-close:hover { opacity: 1; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;
  background: #f8fafc;
}
.chat-msg { display: flex; gap: 10px; max-width: 85%; }
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;
}
.chat-msg.bot .chat-msg-avatar { background: #eff6ff; color: #2563eb; }
.chat-msg.user .chat-msg-avatar { background: #f1f5f9; color: #64748b; }
.chat-msg-bubble {
  padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.7;
}
.chat-msg.bot .chat-msg-bubble { background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-top-left-radius: 4px; }
.chat-msg.user .chat-msg-bubble { background: #2563eb; color: #fff; border-top-right-radius: 4px; }

.chat-typing { display: flex; gap: 4px; padding: 4px 0; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #94a3b8;
  animation: typing 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-input-area {
  padding: 12px 16px; border-top: 1px solid #e2e8f0; display: flex; gap: 10px; flex-shrink: 0;
  background: #fff;
}
.chat-input {
  flex: 1; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 14px;
  font-size: 0.9rem; outline: none; font-family: inherit; resize: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: #2563eb; }
.chat-input::placeholder { color: #94a3b8; }
.chat-send {
  width: 40px; height: 40px; border-radius: 10px; border: none;
  background: #2563eb; color: #fff; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chat-send:hover { background: #1d4ed8; }
.chat-send:disabled { background: #94a3b8; cursor: not-allowed; }
.chat-send svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
  .chat-window { bottom: 80px; right: 16px; left: 16px; width: auto; height: calc(100vh - 100px); }
  .chat-fab { bottom: 20px; right: 20px; width: 52px; height: 52px; }
}
