/**
 * Floating WhatsApp Multi-Admin - Frontend Stylesheet
 * Modern, Lightweight, Accessible, and Mobile-Optimized
 */

:root {
  --fwa-primary: #25D366;
  --fwa-primary-hover: #1EBE5D;
  --fwa-header-bg: #075E54;
  --fwa-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fwa-shadow-button: 0 6px 20px rgba(37, 211, 102, 0.4);
  --fwa-shadow-popup: 0 16px 40px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
  --fwa-radius-card: 20px;
  --fwa-radius-btn: 50%;
  --fwa-z-index: 999999;
}

/* Container Widget */
.fwa-container {
  position: fixed;
  z-index: var(--fwa-z-index);
  font-family: var(--fwa-font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-sizing: border-box;
}

.fwa-container *,
.fwa-container *::before,
.fwa-container *::after {
  box-sizing: border-box;
}

/* Posisi: Bawah Kanan */
.fwa-container.fwa-bottom-right {
  bottom: 26px;
  right: 26px;
}

/* Posisi: Bawah Kiri */
.fwa-container.fwa-bottom-left {
  bottom: 26px;
  left: 26px;
}

/* Visibility Responsive */
@media (max-width: 767px) {
  .fwa-container.fwa-hide-on-mobile {
    display: none !important;
  }
}
@media (min-width: 768px) {
  .fwa-container.fwa-hide-on-desktop {
    display: none !important;
  }
}

/* ========================================================
   FLOATING BUTTON WRAPPER & TOOLTIP
   ======================================================== */
.fwa-button-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.fwa-bottom-left .fwa-button-wrapper {
  flex-direction: row-reverse;
}

/* Label / Tooltip Tombol */
.fwa-btn-label {
  background: #ffffff;
  color: #1f2937;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transform: translateX(0);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.fwa-open .fwa-btn-label {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

/* Tombol Lingkaran Utama */
.fwa-toggle-btn {
  width: 62px;
  height: 62px;
  border-radius: var(--fwa-radius-btn);
  background: var(--fwa-primary);
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--fwa-shadow-button);
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.fwa-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 26px rgba(37, 211, 102, 0.55);
}

.fwa-toggle-btn:active {
  transform: scale(0.95);
}

/* Animasi Tombol: Pulse Gelombang */
.fwa-toggle-btn.fwa-anim-pulse::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--fwa-primary);
  opacity: 0.8;
  animation: fwaPulseEffect 2.2s infinite;
  pointer-events: none;
}

@keyframes fwaPulseEffect {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* Animasi Tombol: Bounce */
.fwa-toggle-btn.fwa-anim-bounce {
  animation: fwaBounceEffect 2.8s infinite ease-in-out;
}

@keyframes fwaBounceEffect {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-9px);
  }
  60% {
    transform: translateY(-4px);
  }
}

.fwa-open .fwa-toggle-btn.fwa-anim-bounce,
.fwa-open .fwa-toggle-btn.fwa-anim-pulse::after {
  animation: none !important;
}

/* Ikon Toggle (WhatsApp vs Close) */
.fwa-btn-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fwa-icon-wa {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.fwa-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.fwa-open .fwa-icon-wa {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.fwa-open .fwa-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Badge Notifikasi */
.fwa-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 20px;
  height: 20px;
  background-color: #ef4444;
  color: #ffffff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  animation: fwaBadgePop 0.4s ease-out;
}

.fwa-open .fwa-badge {
  display: none;
}

@keyframes fwaBadgePop {
  0% { transform: scale(0); }
  80% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ========================================================
   POPUP MODAL / CARD DAFTAR KONTAK
   ======================================================== */
.fwa-popup {
  position: absolute;
  bottom: 80px;
  width: 360px;
  max-width: calc(100vw - 36px);
  background: #ffffff;
  border-radius: var(--fwa-radius-card);
  box-shadow: var(--fwa-shadow-popup);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.fwa-bottom-right .fwa-popup {
  right: 0;
  transform-origin: bottom right;
}

.fwa-bottom-left .fwa-popup {
  left: 0;
  transform-origin: bottom left;
}

/* State Aktif / Terbuka */
.fwa-container.fwa-open .fwa-popup {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header Popup */
.fwa-popup-header {
  background: var(--fwa-header-bg);
  padding: 18px 20px;
  color: #ffffff;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  background-image: linear-gradient(145deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.12) 100%);
}

.fwa-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fwa-header-icon-box {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fwa-header-texts {
  flex: 1;
}

.fwa-header-title {
  margin: 0 0 3px 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
}

.fwa-header-subtitle {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.35;
  font-weight: 400;
}

.fwa-close-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #ffffff;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.fwa-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Daftar Kontak Admin */
.fwa-contacts-body {
  padding: 12px 14px;
  max-height: 380px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Custom Scrollbar */
.fwa-contacts-body::-webkit-scrollbar {
  width: 5px;
}
.fwa-contacts-body::-webkit-scrollbar-track {
  background: transparent;
}
.fwa-contacts-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

/* Baris Kontak Per Admin */
.fwa-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  position: relative;
}

.fwa-contact-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  border-color: rgba(37, 211, 102, 0.3);
  background: #ffffff;
}

/* Avatar Kontak */
.fwa-avatar-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.fwa-agent-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: block;
}

.fwa-online-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

/* Info Kontak */
.fwa-contact-details {
  flex: 1;
  min-width: 0;
}

.fwa-contact-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.fwa-contact-name {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fwa-contact-status-tag {
  font-size: 11px;
  color: #16a34a;
  background: #dcfce7;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.fwa-contact-role {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ikon Tombol Chat Panah / WhatsApp */
.fwa-chat-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0fdf4;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.fwa-contact-item:hover .fwa-chat-action-icon {
  background: var(--fwa-primary);
  color: #ffffff;
  transform: scale(1.1);
}

/* Footer Popup */
.fwa-popup-footer {
  padding: 10px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}

.fwa-footer-text {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.fwa-footer-text::before {
  content: '⚡';
  font-size: 10px;
}

/* ========================================================
   RESPONSIVE DESIGN (HP / MOBILE)
   ======================================================== */
@media (max-width: 480px) {
  .fwa-container.fwa-bottom-right {
    bottom: 18px;
    right: 18px;
  }

  .fwa-container.fwa-bottom-left {
    bottom: 18px;
    left: 18px;
  }

  .fwa-btn-label {
    display: none; /* Sembunyikan teks label di layar HP kecil agar tidak menutupi konten */
  }

  .fwa-toggle-btn {
    width: 56px;
    height: 56px;
  }

  .fwa-popup {
    width: calc(100vw - 36px);
    bottom: 74px;
    right: 0;
    border-radius: 16px;
  }

  .fwa-bottom-left .fwa-popup {
    left: 0;
    right: auto;
  }

  .fwa-contacts-body {
    max-height: 320px;
  }
}
