.chat-widget { position: fixed; right: 28px; bottom: 28px; z-index: 999; font-family: inherit; }

.chat-fab {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2f6bff, #5b8cff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(47, 107, 255, 0.4);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}
.chat-fab:hover { transform: scale(1.07); box-shadow: 0 14px 34px rgba(47, 107, 255, 0.5); }
.chat-fab .chat-fab-icon { display: flex; transition: opacity 0.2s ease, transform 0.25s ease; }
.chat-fab .chat-fab-close { display: none; transition: opacity 0.2s ease; }
.chat-widget.open .chat-fab .chat-fab-icon { display: none; }
.chat-widget.open .chat-fab .chat-fab-close { display: flex; }

.chat-fab-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(47, 107, 255, 0.45);
  animation: chatPulse 2s ease-out infinite;
  pointer-events: none;
}
.chat-widget.open .chat-fab-pulse { display: none; }

@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.7; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(29, 33, 41, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.chat-widget.open .chat-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(120deg, #2f6bff, #5b8cff);
  color: #fff;
  flex-shrink: 0;
}
.chat-head-info { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.chat-head-dot { width: 8px; height: 8px; border-radius: 50%; background: #7dffa9; box-shadow: 0 0 0 3px rgba(125, 255, 169, 0.25); }
.chat-head-status { font-size: 12px; opacity: 0.85; }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg { display: flex; max-width: 82%; animation: chatMsgIn 0.3s ease; }
.chat-msg.agent { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

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

.chat-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  background: #fff;
  color: var(--text-1, #1d2129);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(29, 33, 41, 0.06);
}
.chat-msg.user .chat-bubble {
  background: #2f6bff;
  color: #fff;
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}

.chat-typing { display: flex; gap: 4px; padding: 12px 14px; }
.chat-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b7c3d6;
  animation: chatTyping 1.2s ease-in-out infinite;
}
.chat-typing i:nth-child(2) { animation-delay: 0.18s; }
.chat-typing i:nth-child(3) { animation-delay: 0.36s; }

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

.chat-error {
  align-self: center;
  font-size: 12px;
  color: #d54941;
  background: #fdeaea;
  border-radius: 8px;
  padding: 6px 12px;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-light, #f0f1f3);
  background: #fff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input:focus { border-color: #2f6bff; box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12); }
.chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #2f6bff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.chat-send:hover { background: #1f5bf0; }
.chat-send:active { transform: scale(0.94); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
  .chat-widget { right: 16px; bottom: 16px; }
  .chat-panel { width: calc(100vw - 32px); height: calc(100vh - 110px); }
}
