/* ── Chat Widget ─────────────────────────────────────────────── */

/* Shift back-to-top above the FAB, centered horizontally */
/* Desktop: FAB 56px, back-to-top 44px → offset right by (56-44)/2 = 6px */
.back-to-top {
  bottom: calc(2rem + 56px + 12px) !important;
  right: calc(2rem + 6px) !important;
}
@media (max-width: 768px) {
  .back-to-top { bottom: calc(2rem + 56px + 10px) !important; }
}
/* Mobile: FAB 48px, back-to-top 38px → offset right by (48-38)/2 = 5px */
@media (max-width: 480px) {
  .back-to-top {
    bottom: calc(1.25rem + 48px + 10px) !important;
    right: calc(1.25rem + 5px) !important;
  }
}

/* ── Floating Action Button ──────────────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9992;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
  transition: transform 0.25s ease, background 0.25s ease;
}
.chat-fab:hover {
  transform: scale(1.1);
  background: #1ebe57;
}
.chat-fab svg {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.chat-fab--active svg.chat-fab__icon-chat { opacity: 0; transform: rotate(90deg) scale(0.5); }
.chat-fab--active svg.chat-fab__icon-close { opacity: 1; transform: rotate(0) scale(1); }
svg.chat-fab__icon-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.5); }

/* Pulse ring */
.chat-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #25D366;
  animation: chat-pulse 2s ease-out infinite;
}
.chat-fab--active::before { animation: none; opacity: 0; }

@keyframes chat-pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* ── Chat Panel ──────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  z-index: 9992;
  width: 320px;
  max-height: 420px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(17,17,17,0.1));
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-panel.hidden {
  display: none;
}

/* ── Panel Header ────────────────────────────────────────────── */
.chat-panel__header {
  background: #25D366;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px 12px 0 0;
  position: relative;
}
.chat-panel__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-panel__info { flex: 1; }
.chat-panel__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}
.chat-panel__status {
  font-size: 0.72rem;
  opacity: 0.85;
}
.chat-panel__close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.chat-panel__close:hover { opacity: 1; }

/* ── Panel Body ──────────────────────────────────────────────── */
.chat-panel__body {
  padding: 16px;
  background: var(--bg, #f5f4f0);
  flex: 1;
}
.chat-panel__bubble {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(17,17,17,0.1));
  border-radius: 0 10px 10px 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text, #111);
  max-width: 90%;
}
.chat-panel__time {
  font-size: 0.68rem;
  color: var(--muted, #888);
  margin-top: 6px;
}

/* ── Quick Replies ───────────────────────────────────────────── */
.chat-panel__actions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg, #f5f4f0);
}
.chat-panel__quick {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(17,17,17,0.1));
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text, #111);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.chat-panel__quick:hover {
  border-color: #25D366;
  color: #25D366;
}

/* ── WhatsApp CTA ────────────────────────────────────────────── */
.chat-panel__wa-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25D366;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 12px 16px;
  border-radius: 0 0 12px 12px;
  transition: background 0.2s;
}
.chat-panel__wa-link:hover {
  background: #1ebe57;
}
.chat-panel__wa-link svg {
  width: 18px;
  height: 18px;
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-fab {
    width: 48px;
    height: 48px;
    bottom: 1.25rem;
    right: 1.25rem;
  }
  .chat-fab svg { width: 24px; height: 24px; }
  .chat-panel {
    left: 1rem;
    right: 1rem;
    bottom: 5rem;
    width: auto;
  }
}
