/* ═══════════════════════════════════════════════════════
   FLOATING CHAT WIDGET
   ═══════════════════════════════════════════════════════ */

/* --- Floating Action Button --- */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5),
              0 2px 6px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.3s ease;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6),
              0 3px 10px rgba(0, 0, 0, 0.3);
}

.chat-fab:active {
  transform: scale(0.95);
}

/* Icon inside the FAB */
.chat-fab svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-fab .chat-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg);
}

.chat-fab.active .chat-icon-msg {
  opacity: 0;
  transform: rotate(90deg);
}

.chat-fab.active .chat-icon-close {
  opacity: 1;
  transform: rotate(0deg);
}

/* Subtle pulse animation when idle */
@keyframes chatPulse {
  0%   { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(0,0,0,0.4); }
  70%  { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 12px rgba(0,0,0,0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(0,0,0,0); }
}

@keyframes chatPulseDark {
  0%   { box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 0 0 rgba(255,255,255,0.25); }
  70%  { box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 0 12px rgba(255,255,255,0); }
  100% { box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 0 0 rgba(255,255,255,0); }
}

.chat-fab:not(.active) {
  animation: chatPulse 2.5s ease-in-out infinite;
}

[data-theme="dark"] .chat-fab:not(.active) {
  animation: chatPulseDark 2.5s ease-in-out infinite;
}

.chat-fab.active {
  animation: none;
}

/* Dark mode styling for Floating Action Button */
[data-theme="dark"] .chat-fab {
  background: linear-gradient(135deg, #282c37 0%, #1a1d26 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7),
              0 0 14px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .chat-fab:hover {
  background: linear-gradient(135deg, #343a49 0%, #222632 100%);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.8),
              0 0 18px rgba(255, 255, 255, 0.16);
}

[data-theme="dark"] .chat-fab.active {
  background: linear-gradient(135deg, #373c4a 0%, #242835 100%);
  border-color: rgba(255, 255, 255, 0.4);
}


/* --- Popup Menu --- */
.chat-popup {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 280px;
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px 12px 12px 2px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15),
              0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease,
              transform 0.3s cubic-bezier(.34,1.56,.64,1),
              visibility 0.3s ease;
  overflow: hidden;
}

[data-theme="dark"] .chat-popup {
  background: #1c1f27;
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75),
              0 0 20px rgba(0, 0, 0, 0.4);
}

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

/* Header inside popup */
.chat-popup-header {
  padding: 16px 20px 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  letter-spacing: -0.01em;
}

[data-theme="dark"] .chat-popup-header {
  color: #f3f4f6;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* Links list */
.chat-popup-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.chat-popup-list li {
  margin: 0;
}

.chat-popup-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.18s ease;
  border-left: 3px solid transparent;
}

[data-theme="dark"] .chat-popup-list a {
  color: #f3f4f6;
}

.chat-popup-list a:hover {
  background: var(--bg-hover, rgba(128,128,128,0.1));
  border-left-color: var(--accent-primary);
}

[data-theme="dark"] .chat-popup-list a:hover {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #60a5fa;
}

/* Channel icons */
.chat-channel-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-channel-icon svg {
  width: 20px;
  height: 20px;
}

.chat-channel-icon.whatsapp  { background: #25D366; }
.chat-channel-icon.email     { background: #5B7FFF; }
.chat-channel-icon.messenger { background: #0084FF; }
.chat-channel-icon.telegram  { background: #2AABEE; }

.chat-channel-icon svg { fill: #fff; }


/* --- Backdrop overlay (mobile-friendly) --- */
.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-backdrop.open {
  opacity: 1;
  visibility: visible;
}


/* --- Mobile tweaks --- */
@media (max-width: 480px) {
  .chat-fab {
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
  }

  .chat-fab svg {
    width: 24px;
    height: 24px;
  }

  .chat-popup {
    right: 16px;
    bottom: 86px;
    width: calc(100vw - 32px);
    max-width: 320px;
  }
}
