/**
 * Premium WhatsApp Business widget — matches existing brand tokens.
 * Does not redesign site layouts/colors.
 */

:root {
  --wa-green: #25d366;
  --wa-green-deep: #128c7e;
  --wa-ink: #0a2540;
  --wa-glass: rgba(255, 255, 255, 0.78);
  --wa-shadow: 0 16px 40px rgba(10, 37, 64, 0.22);
}

.wa-launcher {
  position: fixed;
  right: 22px;
  bottom: 92px; /* sits above AI launcher */
  z-index: 10046;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  background: linear-gradient(145deg, rgba(37, 211, 102, 0.95), rgba(18, 140, 126, 0.95));
  box-shadow: var(--wa-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  isolation: isolate;
}

.wa-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 20px 48px rgba(18, 140, 126, 0.35);
}

.wa-launcher::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.45);
  animation: waPulseRing 10s ease-out infinite;
  pointer-events: none;
}

@keyframes waPulseRing {
  0%, 85% { transform: scale(0.92); opacity: 0; }
  88% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}

.wa-launcher .wa-ripple {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: scale(0);
  animation: waRipple 0.55s ease-out forwards;
  pointer-events: none;
}

@keyframes waRipple {
  to { transform: scale(8); opacity: 0; }
}

.wa-status-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #22c55e;
}

.wa-status-dot.is-offline {
  background: #ef4444;
}

.wa-panel {
  position: fixed;
  right: 22px;
  bottom: 162px;
  width: min(340px, calc(100vw - 24px));
  z-index: 10047;
  border-radius: 20px;
  overflow: hidden;
  background: var(--wa-glass);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--wa-shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.96);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
}

.wa-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.wa-panel-header {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--wa-ink), var(--wa-green-deep));
  color: #fff;
}

.wa-panel-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: #fff;
}

.wa-panel-header h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.wa-panel-header p {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.88;
}

.wa-online-pill {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}

.wa-body {
  padding: 0.9rem 1rem 1rem;
}

.wa-bubble {
  background: #fff;
  border: 1px solid rgba(10, 37, 64, 0.08);
  border-radius: 14px 14px 14px 4px;
  padding: 0.75rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #0f172a;
  box-shadow: 0 8px 20px rgba(10, 37, 64, 0.06);
  animation: waBubbleIn 0.4s ease both;
}

@keyframes waBubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wa-offline-note {
  margin-top: 0.55rem;
  font-size: 0.75rem;
  color: #64748b;
}

.wa-actions {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.wa-action {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 1px solid rgba(0, 86, 179, 0.12);
  background: #fff;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font-size: 0.82rem;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.wa-action:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 211, 102, 0.45);
  box-shadow: 0 8px 18px rgba(10, 37, 64, 0.08);
}

.wa-action span[aria-hidden] {
  font-size: 1rem;
}

.wa-cta-row {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.wa-btn {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wa-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-deep));
  box-shadow: 0 10px 24px rgba(18, 140, 126, 0.28);
}

.wa-btn-primary:hover {
  transform: translateY(-2px);
}

.wa-btn-ghost {
  background: rgba(15, 23, 42, 0.05);
  color: #334155;
}

.wa-close-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.wa-welcome-card {
  position: fixed;
  right: 22px;
  bottom: 170px;
  z-index: 10048;
  width: min(300px, calc(100vw - 28px));
  border-radius: 18px;
  padding: 1rem 1rem 0.9rem;
  background: var(--wa-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--wa-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.wa-welcome-card.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.wa-welcome-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: var(--wa-ink);
}

.wa-welcome-card p {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.45;
}

.wa-lead-modal {
  position: fixed;
  inset: 0;
  z-index: 10055;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 37, 64, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.wa-lead-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.wa-lead-card {
  width: min(420px, 100%);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--wa-shadow);
  padding: 1.1rem 1.15rem 1rem;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
}

.wa-lead-modal.is-open .wa-lead-card {
  transform: translateY(0) scale(1);
}

.wa-lead-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--wa-ink);
}

.wa-lead-card .form-control,
.wa-lead-card .form-select {
  font-size: 0.88rem;
}

.wa-lead-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

/* Keep AI launcher below WhatsApp */
.ai-launcher {
  bottom: 22px;
}

@media (max-width: 575.98px) {
  .wa-launcher {
    right: 14px;
    bottom: 84px;
  }
  .wa-panel,
  .wa-welcome-card {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 150px;
  }
  .ai-launcher {
    right: 14px;
    bottom: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wa-launcher,
  .wa-launcher::before,
  .wa-panel,
  .wa-welcome-card,
  .wa-bubble,
  .wa-action,
  .wa-btn {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  .wa-panel,
  .wa-welcome-card {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(255, 255, 255, 0.12);
  }
  .wa-bubble,
  .wa-action,
  .wa-lead-card {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.08);
  }
  .wa-welcome-card h4,
  .wa-lead-card h4 {
    color: #f8fafc;
  }
  .wa-welcome-card p,
  .wa-offline-note {
    color: #94a3b8;
  }
}
