/* ---------- Lead-capture chat widget ---------- */
.apack-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.15s ease, background 0.15s ease;
}
.apack-chat-launcher:hover { background: var(--color-primary-dark); transform: scale(1.05); }
.apack-chat-launcher svg { width: 26px; height: 26px; }
.apack-chat-launcher .apack-chat-close-icon { display: none; }
.apack-chat-launcher.open .apack-chat-chat-icon { display: none; }
.apack-chat-launcher.open .apack-chat-close-icon { display: block; }

.apack-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-secondary);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: var(--font-body);
}

.apack-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: 340px;
  max-width: calc(100vw - 40px);
  height: 460px;
  max-height: calc(100vh - 140px);
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-family: var(--font-body);
  border: 1px solid var(--color-border);
}
.apack-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.apack-chat-header {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.apack-chat-header .apack-chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.apack-chat-header .apack-chat-avatar svg { width: 18px; height: 18px; }
.apack-chat-header-text { line-height: 1.25; }
.apack-chat-header-text strong { display: block; font-family: var(--font-head); font-size: 14px; }
.apack-chat-header-text span { font-size: 12px; opacity: 0.9; }

.apack-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-bg);
}

.apack-chat-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.apack-chat-msg.bot {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  color: var(--color-ink);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.apack-chat-msg.user {
  background: var(--color-primary);
  color: var(--color-white);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.apack-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
}
.apack-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-ink-soft);
  opacity: 0.5;
  animation: apack-chat-bounce 1.2s infinite ease-in-out;
}
.apack-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.apack-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes apack-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.apack-chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}
.apack-chat-quick-replies button {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--color-primary);
  background: var(--color-white);
  color: var(--color-primary-dark);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.apack-chat-quick-replies button:hover {
  background: var(--color-primary);
  color: var(--color-white);
}

.apack-chat-footer {
  border-top: 1px solid var(--color-border);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--color-card);
}
.apack-chat-footer input {
  flex: 1;
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--color-ink);
  background: var(--color-bg);
  outline: none;
}
.apack-chat-footer input:focus { border-color: var(--color-primary); }
.apack-chat-footer button {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apack-chat-footer button:hover { background: var(--color-primary-dark); }
.apack-chat-footer button:disabled { opacity: 0.5; cursor: not-allowed; }
.apack-chat-footer svg { width: 16px; height: 16px; }

@media (max-width: 480px) {
  .apack-chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 86px;
  }
  .apack-chat-launcher { right: 16px; bottom: 16px; }
}
