/* ==========================================================================
   Chat Widget
   ========================================================================== */
.chat-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  font-family: "Inter", sans-serif;
}

.chat-toggle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--primary-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-window {
  position: absolute;
  bottom: 4.5rem;
  right: 0;
  width: 350px;
  height: 500px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.chat-widget.active .chat-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  padding: 1rem;
  background-color: var(--secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.chat-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.chat-close:hover {
  color: var(--foreground);
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.message {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.message.bot .message-content {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border-bottom-left-radius: 0.25rem;
}

.message.user .message-content {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 0.25rem;
}

.message-content a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

.message-time {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  margin-left: 0.5rem;
}

.message.user .message-time {
  margin-left: 0;
  margin-right: 0.5rem;
  text-align: right;
}

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  background-color: var(--card);
}

#chat-input {
  flex: 1;
  background-color: var(--input);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.75rem 1rem;
  color: var(--foreground);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.2s ease;
}

#chat-input:focus {
  border-color: var(--primary);
}

.chat-send {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.chat-send:hover {
  transform: scale(1.05);
}

/* Typing Indicator */
.message.typing .message-content {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1rem;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--muted-foreground);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 2rem);
    right: -1rem;
    bottom: 4rem;
    height: 60vh;
  }
}
