/* ===========================
   AI Chat Widget Styles
   =========================== */

/* Trigger Button */
.ai-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-cyan));
  border: none;
  cursor: pointer;
  z-index: 9001;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-contrast);
  box-shadow: 0 4px 20px var(--accent-border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ai-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px var(--accent-border);
}

.ai-chat-trigger .ai-icon-close {
  display: none;
}

.ai-chat.open .ai-chat-trigger .ai-icon-open {
  display: none;
}

.ai-chat.open .ai-chat-trigger .ai-icon-close {
  display: block;
}

/* Pulse animation */
.ai-chat-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--brand-accent);
  animation: chatPulse 2s ease-out infinite;
  pointer-events: none;
}

.ai-chat.open .ai-chat-pulse {
  display: none;
}

@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Chat Panel */
.ai-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  border-radius: var(--radius-xl);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 9000;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.ai-chat.open .ai-chat-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.ai-chat-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.ai-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-card-solid);
}

.ai-chat-header h4 {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0;
}

.ai-chat-header p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
}

.ai-chat-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.ai-chat-close:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 300px;
}

.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* Message Bubbles */
.ai-msg p {
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
}

.ai-msg-bot {
  align-self: flex-start;
  max-width: 85%;
}

.ai-msg-bot p {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  color: var(--text-primary);
}

.ai-msg-user {
  align-self: flex-end;
  max-width: 85%;
}

.ai-msg-user p {
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-cyan));
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  color: var(--accent-contrast);
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px 16px 16px 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Suggestion Chips */
.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 20px 4px;
}

.ai-suggestion {
  font-family: inherit;
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.ai-suggestion:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  background: var(--accent-soft);
}

/* Input Area */
.ai-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.ai-chat-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.ai-chat-form input::placeholder {
  color: var(--text-muted);
}

.ai-chat-form input:focus {
  border-color: var(--brand-accent);
}

.ai-chat-form button[type="submit"] {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-cyan));
  border: none;
  color: var(--accent-contrast);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.ai-chat-form button[type="submit"]:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--accent-border);
}

/* ===========================
   Responsive - Mobile
   =========================== */
@media (max-width: 768px) {
  .ai-chat-trigger {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .ai-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .ai-chat.open .ai-chat-trigger {
    display: none;
  }

  .ai-chat-messages {
    max-height: 50vh;
  }
}
