/* ========== CHAT WIDGET ========== */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--color-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(23, 188, 208, 0.3);
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(23, 188, 208, 0.4);
}

.chat-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--color-bg);
}

.chat-toggle .chat-close {
  display: none;
}

.chat-toggle.active .chat-icon { display: none; }
.chat-toggle.active .chat-close { display: block; }

/* Chat panel */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: pulse-dot 2s ease-in-out infinite;
}

.chat-header__title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-text-bright);
}

.chat-header__status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-primary);
  margin-left: auto;
  letter-spacing: 1px;
}

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

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.chat-msg--user {
  align-self: flex-end;
  background: rgba(23, 188, 208, 0.1);
  border: 1px solid rgba(23, 188, 208, 0.2);
  color: var(--color-text-bright);
}

.chat-msg--typing {
  align-self: flex-start;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  padding: 12px 18px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

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

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

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

/* Input */
.chat-input {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 8px;
}

.chat-input input {
  flex: 1;
  background: #000;
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  color: var(--color-text-bright);
  font-family: var(--font-body);
  font-size: 13px;
  transition: var(--transition);
}

.chat-input input:focus {
  outline: none;
  border-color: var(--color-primary);
}

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

.chat-input button {
  background: var(--color-primary);
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-bg);
  transition: var(--transition);
}

.chat-input button:hover {
  box-shadow: 0 4px 16px rgba(23, 188, 208, 0.3);
}

.chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Lead capture form inside chat */
.chat-lead-form {
  padding: 12px 14px;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  align-self: flex-start;
  max-width: 90%;
}

.chat-lead-form p {
  font-size: 12px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.chat-lead-form input {
  width: 100%;
  background: #000;
  border: 1px solid var(--color-border);
  padding: 6px 8px;
  color: var(--color-text-bright);
  font-size: 12px;
  margin-bottom: 6px;
  font-family: var(--font-body);
}

.chat-lead-form input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-lead-form button {
  background: var(--color-primary);
  border: none;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-bg);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
  }

  .chat-toggle {
    bottom: 16px;
    right: 16px;
  }
}
