/* ==========================================================================
   Luxury Multi-Agent WhatsApp Floating Widget (2026 B2B Edition)
   Designed for Saradeeb · High-end, Responsive, Accessible, Clutter-Free
   ========================================================================== */

:root {
  --wa-brand: #157176;
  --wa-brand-rgb: 21, 113, 118;
  --wa-brand-hover: #125e62;
  --wa-card-bg: #ffffff;
  --wa-card-text: #0f172a;
  --wa-card-muted: #64748b;
  --wa-card-border: #e2e8f0;
  --wa-card-item-bg: #f8fafc;
  --wa-card-item-hover: #f1f5f9;
  --wa-status-online: #10b981;
}

html.dark, body.dark, [data-theme="dark"] {
  --wa-card-bg: #0f1720;
  --wa-card-text: #f8fafc;
  --wa-card-muted: #94a3b8;
  --wa-card-border: rgba(255, 255, 255, 0.09);
  --wa-card-item-bg: rgba(255, 255, 255, 0.035);
  --wa-card-item-hover: rgba(21, 113, 118, 0.15);
}

/* --- Container & Floating Dock --- */
#wa-widget-root {
  position: fixed;
  bottom: 24px;
  z-index: 99999;
  font-family: inherit;
  pointer-events: auto;
  box-sizing: border-box;
}

#wa-widget-root *,
#wa-widget-root *::before,
#wa-widget-root *::after {
  box-sizing: border-box;
}

#wa-widget-root.wa-dock-right {
  right: 24px;
  left: auto;
}

#wa-widget-root.wa-dock-left {
  left: 24px;
  right: auto;
}

@media (max-width: 767px) {
  #wa-widget-root {
    bottom: 18px;
  }
  #wa-widget-root.wa-dock-right {
    right: 16px;
  }
  #wa-widget-root.wa-dock-left {
    left: 16px;
  }
}

/* --- 1. Floating WhatsApp Button --- */
.wa-floating-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--wa-brand, #157176);
  color: #ffffff;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(var(--wa-brand-rgb, 21, 113, 118), 0.45),
              0 0 35px rgba(var(--wa-brand-rgb, 21, 113, 118), 0.22);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease,
              background 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 767px) {
  .wa-floating-btn {
    width: 46px;
    height: 46px;
  }
}

.wa-floating-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 26px rgba(var(--wa-brand-rgb, 21, 113, 118), 0.65),
              0 0 45px rgba(var(--wa-brand-rgb, 21, 113, 118), 0.35);
}

.wa-floating-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

/* Outer Translucent Ring */
.wa-outer-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  pointer-events: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.wa-floating-btn:hover .wa-outer-ring {
  border-color: rgba(255, 255, 255, 0.75);
}

/* Sweeping Sparkle Lens Flare */
.wa-sparkle-lens {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  pointer-events: none;
  animation: waSparkleSweep 4.5s ease-in-out infinite;
  transform-origin: center center;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

@keyframes waSparkleSweep {
  0%, 75% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  80% {
    opacity: 1;
    transform: scale(1.15) rotate(15deg);
  }
  85% {
    opacity: 0.9;
    transform: scale(0.95) rotate(30deg);
  }
  90% {
    opacity: 1;
    transform: scale(1.05) rotate(45deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(90deg);
  }
}

/* Status Badge (13px pinned at 5 o'clock in all layouts) */
.wa-status-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--wa-brand, #157176);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* Icons inside the button */
.wa-icon-holder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.wa-btn-svg {
  width: 28px;
  height: 28px;
  display: block;
}

@media (max-width: 767px) {
  .wa-btn-svg {
    width: 24px;
    height: 24px;
  }
}

.wa-close-svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Toggle transition between WhatsApp icon and Close icon */
.wa-floating-btn .wa-close-icon {
  display: none;
}

.wa-floating-btn.wa-is-open .wa-whatsapp-icon {
  display: none;
}

.wa-floating-btn.wa-is-open .wa-close-icon {
  display: flex;
}

/* --- 2. Multi-Agent Contact Popup Panel --- */
.wa-popup-panel {
  position: absolute;
  bottom: calc(100% + 14px);
  width: min(300px, calc(100vw - 32px));
  background: var(--wa-card-bg, #ffffff);
  color: var(--wa-card-text, #0f172a);
  border: 1px solid var(--wa-card-border, #e2e8f0);
  border-top: 3px solid var(--wa-brand, #157176);
  border-radius: 1.25rem;
  box-shadow: 0 24px 50px -12px rgba(15, 23, 42, 0.22),
              0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.97);
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 200ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

/* Alignment of panel based on dock */
#wa-widget-root.wa-dock-right .wa-popup-panel {
  right: 0;
  left: auto;
  transform-origin: bottom right;
}

#wa-widget-root.wa-dock-left .wa-popup-panel {
  left: 0;
  right: auto;
  transform-origin: bottom left;
}

.wa-popup-panel.wa-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Panel Header */
.wa-panel-header {
  padding: 16px 16px 12px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--wa-card-border, #e2e8f0);
}

.wa-header-brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wa-header-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(var(--wa-brand-rgb, 21, 113, 118), 0.12);
  color: var(--wa-brand, #157176);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(var(--wa-brand-rgb, 21, 113, 118), 0.18);
}

.wa-header-icon-badge svg {
  width: 20px;
  height: 20px;
}

.wa-header-texts {
  min-width: 0;
}

.wa-header-title {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: var(--wa-card-text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-header-subtitle {
  font-size: 11.5px;
  color: var(--wa-card-muted, #64748b);
  margin: 2px 0 0 0;
  line-height: 1.35;
}

.wa-panel-close-btn {
  background: transparent;
  border: none;
  color: var(--wa-card-muted, #64748b);
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease, background 0.18s ease;
  flex-shrink: 0;
}

.wa-panel-close-btn:hover {
  color: var(--wa-card-text, #0f172a);
  background: rgba(0, 0, 0, 0.05);
}

html.dark .wa-panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.wa-panel-close-btn svg {
  width: 16px;
  height: 16px;
}

/* Panel Body / Department Cards */
.wa-panel-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wa-agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--wa-card-item-bg, #f8fafc);
  border: 1px solid var(--wa-card-border, #e2e8f0);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease,
              background 0.18s ease,
              border-color 0.18s ease,
              box-shadow 0.18s ease;
  cursor: pointer;
}

.wa-agent-card:hover {
  background: var(--wa-card-item-hover, #f1f5f9);
  border-color: rgba(var(--wa-brand-rgb, 21, 113, 118), 0.4);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

/* Avatar / Desk Initial */
.wa-agent-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(var(--wa-brand-rgb, 21, 113, 118), 0.22), rgba(var(--wa-brand-rgb, 21, 113, 118), 0.08));
  color: var(--wa-brand, #157176);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(var(--wa-brand-rgb, 21, 113, 118), 0.25);
}

.wa-agent-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--wa-status-online, #10b981);
  border: 2px solid var(--wa-card-bg, #ffffff);
}

/* Agent Info */
.wa-agent-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-agent-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.wa-agent-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--wa-card-text, #0f172a);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Live availability status pill */
.wa-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 6px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  flex-shrink: 0;
}

html.dark .wa-status-pill {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.wa-pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: waPulseGreen 2s infinite;
}

@keyframes waPulseGreen {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.wa-agent-desc {
  font-size: 11px;
  color: var(--wa-card-muted, #64748b);
  margin: 0;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-agent-phone {
  font-size: 11px;
  font-weight: 600;
  color: var(--wa-brand, #157176);
  direction: ltr !important;
  text-align: left;
  letter-spacing: 0.2px;
  margin-top: 1px;
}

/* Card Action Arrow */
.wa-agent-action {
  color: var(--wa-card-muted, #64748b);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s ease, color 0.18s ease;
}

.wa-agent-card:hover .wa-agent-action {
  color: var(--wa-brand, #157176);
  transform: translateX(-2px);
}

[dir="ltr"] .wa-agent-card:hover .wa-agent-action {
  transform: translateX(2px);
}

/* Panel Footer */
.wa-panel-footer {
  padding: 10px 14px;
  background: var(--wa-card-item-bg, #f8fafc);
  border-top: 1px solid var(--wa-card-border, #e2e8f0);
  text-align: center;
}

.wa-footer-response {
  font-size: 11px;
  font-weight: 600;
  color: var(--wa-card-muted, #64748b);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* --- Accessibility & Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .wa-floating-btn,
  .wa-popup-panel,
  .wa-agent-card,
  .wa-agent-action {
    transition: none !important;
  }
  .wa-sparkle-lens {
    animation: none !important;
  }
  .wa-pulse-dot {
    animation: none !important;
  }
}
