/* === Chat Widget === */
.chat-widget {
  position: fixed;
  bottom: 28px;
  right: 104px;
  z-index: 998;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

/* Toggle Button */
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8, #4f9cf5);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(26, 115, 232, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(26, 115, 232, 0.45);
}

.chat-toggle.open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}

.chat-toggle .toggle-icon-open,
.chat-toggle .toggle-icon-close {
  position: absolute;
  transition: all 0.3s;
}

.chat-toggle .toggle-icon-close {
  opacity: 0;
  transform: rotate(-90deg);
}

.chat-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* Chat Panel */
.chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 380px;
  height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #1a73e8, #4f9cf5);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.chat-header-info h4 {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.chat-header-info span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.chat-close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Chat Body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
  width: 4px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Chat Messages */
.chat-msg {
  display: flex;
  gap: 8px;
  animation: slide-up 0.3s ease-out;
  max-width: 90%;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.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%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg.bot .chat-msg-avatar {
  background: #e0f2fe;
}

.chat-msg.user .chat-msg-avatar {
  background: #e8f0fe;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: #1e293b;
}

.chat-msg.bot .chat-msg-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-msg.user .chat-msg-bubble {
  background: #1a73e8;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 14px;
}

.chat-msg.user .chat-msg-time {
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
}

/* Typing Indicator */
.chat-typing {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: max-content;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-typing.visible {
  display: flex;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick Replies */
.quick-replies {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 8px;
}

.quick-replies.visible {
  display: flex;
}

.quick-reply-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid #1a73e8;
  background: #fff;
  color: #1a73e8;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-reply-btn:hover {
  background: #1a73e8;
  color: #fff;
}

/* Chat Footer */
.chat-footer {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.08);
}

.chat-input::placeholder {
  color: #94a3b8;
}

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-send:hover {
  background: #1557b0;
  transform: scale(1.05);
}

.chat-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Send Transcript Button */
.chat-transcript-send {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-transcript-send.visible {
  display: flex;
}

.chat-transcript-send:hover {
  background: #15803d;
}

.chat-transcript-send:disabled {
  background: #86efac;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-widget {
    right: 16px;
    bottom: 88px;
  }

  .chat-panel {
    width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 160px);
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 88px;
    right: 16px;
    left: 16px;
  }

  .chat-toggle {
    bottom: 20px;
  }
}
