/* =============================================
   CHAT WIDGET
   ============================================= */

.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10001;
  box-shadow: var(--shadow-lg);
  transition: transform var(--trans), background var(--trans);
  border: none;
}
.chat-bubble:hover {
  transform: scale(1.08);
}
.chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

/* Panel */
.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-header-close {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  font-size: 1.25rem;
  opacity: 0.7;
  transition: opacity var(--trans);
}
.chat-header-close:hover {
  opacity: 1;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Individual message */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg a {
  text-decoration: underline;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--white);
}
.chat-msg-user a { color: var(--white); }
.chat-msg-bot {
  align-self: flex-start;
  background: var(--bg-2);
  color: var(--ink);
}
.chat-msg-bot a { color: var(--accent); }

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-radius: var(--radius-lg);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: chat-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 chat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--white);
  color: var(--ink);
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: var(--muted);
}
.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--trans);
}
.chat-send:hover {
  background: #d04018;
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Rate limit notice */
.chat-rate-limit {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 6px 16px 0;
}

/* Mobile full-screen */
@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
  .chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}
