/* chat-widget.css — Flow-AI floating chat assistant */

.chat-launcher {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}
.chat-launcher:hover {
  background: var(--color-primary-hover);
}
.chat-launcher svg {
  width: 24px;
  height: 24px;
}
.chat-launcher[data-open='true'] .icon-open {
  display: none;
}
.chat-launcher:not([data-open='true']) .icon-close {
  display: none;
}

.chat-panel {
  position: fixed;
  bottom: calc(var(--space-6) + 68px);
  right: var(--space-6);
  z-index: 90;
  width: min(380px, calc(100vw - 2.5rem));
  height: min(560px, calc(100vh - 140px));
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-panel[data-open='true'] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel {
    transition: opacity 200ms ease;
    transform: none;
  }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  flex-shrink: 0;
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.chat-header-title svg {
  width: 22px;
  height: 22px;
  color: var(--color-primary);
}
.chat-header-title strong {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  display: block;
}
.chat-header-title span {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.chat-header-title span::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-success);
  display: inline-block;
}
.chat-header-actions {
  display: flex;
  gap: var(--space-1);
}
.chat-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}
.chat-close-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}
.chat-close-btn svg {
  width: 16px;
  height: 16px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-msg {
  max-width: 84%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg--bot {
  align-self: flex-start;
  background: var(--color-surface-offset);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}
.chat-msg--error {
  align-self: flex-start;
  background: var(--color-error-highlight);
  color: var(--color-error);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-msg--bot p {
  margin: 0 0 var(--space-2) 0;
}
.chat-msg--bot p:last-child {
  margin-bottom: 0;
}
.chat-msg--bot ul {
  margin: 0 0 var(--space-2) 0;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.chat-msg--bot ul:last-child {
  margin-bottom: 0;
}
.chat-msg--bot hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-3) 0;
}
.chat-msg--bot .chat-msg-heading {
  display: block;
  margin: var(--space-1) 0 var(--space-2) 0;
  font-size: var(--text-sm);
}
.chat-msg--bot strong {
  font-weight: 700;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 0.3rem;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-text-faint);
  animation: chat-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chat-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-divider);
  flex-shrink: 0;
  background: var(--color-surface);
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  min-height: 44px;
  max-height: 120px;
  background: var(--color-surface-2);
  font-family: var(--font-body);
  color: var(--color-text);
}
.chat-input-row textarea:focus {
  border-color: var(--color-primary);
}
.chat-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-send-btn:hover {
  background: var(--color-primary-hover);
}
.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 640px) {
  .chat-panel {
    width: calc(100vw - 1.5rem);
    height: min(70vh, calc(100vh - 120px));
    bottom: calc(var(--space-4) + 64px);
    right: var(--space-3);
  }
  .chat-launcher {
    bottom: var(--space-4);
    right: var(--space-4);
  }
}
