/* =========================================================
   ChatBot styles
   ========================================================= */

.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 32px -8px color-mix(in srgb, var(--accent) 60%, transparent), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform .25s cubic-bezier(.2,.7,.2,1), box-shadow .25s, background .25s;
  border: 0;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab.open { background: var(--text); }
.chat-fab .fab-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.chat-fab .fab-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: chat-pulse 2.4s infinite;
}
@keyframes chat-pulse {
  0%   { transform: scale(1);   opacity: 0.4; }
  70%  { transform: scale(1.5); opacity: 0;   }
  100% { transform: scale(1.5); opacity: 0;   }
}

@media (max-width: 600px) {
  .chat-fab { bottom: 16px; right: 16px; width: 54px; height: 54px; }
}

/* ---------- Window ---------- */
.chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 79;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 80px -20px rgba(20, 18, 14, 0.28), 0 8px 24px -12px rgba(20, 18, 14, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity .25s, transform .25s cubic-bezier(.2,.7,.2,1);
  transform-origin: bottom right;
}
.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 600px) {
  .chat-window {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 84px;
    height: calc(100vh - 110px);
  }
}

/* ---------- Header ---------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--text);
  color: var(--bg);
  position: relative;
}
.chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar .led {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4caf50;
  border: 2px solid var(--text);
}
.chat-h-text { flex: 1; min-width: 0; }
.chat-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.chat-sub {
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--bg) 65%, transparent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.chat-sub .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4caf50;
}
.chat-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 12%, transparent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  transition: background .2s;
}
.chat-close:hover { background: color-mix(in srgb, var(--bg) 22%, transparent); }

/* ---------- Body ---------- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 86%;
  animation: chat-msg-in .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { align-self: flex-end; }
.chat-msg.user .bubble {
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 6px;
}
.chat-msg.assistant { align-self: flex-start; }
.chat-msg.assistant .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  text-wrap: pretty;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Typing dots */
.bubble.typing {
  padding: 14px 18px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.bubble.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-mute);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* WhatsApp button */
.wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: #25d366;
  color: #fff !important;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s, transform .2s;
  align-self: flex-start;
  width: fit-content;
}
.wa-btn:hover { background: #1ebe5a; transform: translateY(-1px); }
.wa-btn svg { flex-shrink: 0; }

/* ---------- Suggestions ---------- */
.chat-suggestions {
  padding: 0 18px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg);
}
.chat-suggestions button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.chat-suggestions button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-2));
}

/* ---------- Input ---------- */
.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.chat-input input {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color .2s;
}
.chat-input input::placeholder { color: var(--text-mute); }
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s, background .2s, opacity .2s;
}
.chat-input button:hover:not(:disabled) { transform: scale(1.05); }
.chat-input button:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-input button svg { margin-left: -2px; }
