/* ============================================================
   Floating chat widget
   ============================================================ */

#chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: var(--font-sans);
}

.chat-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.chat-launcher:hover {
  transform: scale(1.06);
}

.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel.open {
  display: flex;
}

.chat-header {
  background: var(--color-primary);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header .title {
  font-weight: 700;
  font-size: 0.95rem;
}

.chat-header .subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--color-background);
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chat-bubble.bot {
  background: var(--color-surface);
  border: 1px solid rgba(0, 0, 0, 0.08);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: var(--color-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px;
}

.chat-bubble.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: chat-typing 1.2s infinite ease-in-out;
}

.chat-bubble.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-quick-actions {
  padding: 0 16px 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-quick-actions button {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--color-surface);
  cursor: pointer;
}

.chat-quick-actions button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--color-surface);
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  font-family: inherit;
}

.chat-input-row button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
}

.chat-input-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 420px) {
  .chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
  }
}
