/**
 * God of Graphics - Floating WhatsApp Chat Support Widget
 * Modern, responsive, and high-conversion support popup
 */

:root {
  --wa-green: #25D366;
  --wa-green-dark: #128C7E;
  --wa-teal: #075E54;
  --wa-teal-deep: #054c44;
  --wa-bg-chat: #efeae2;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #dcf8c6;
  --wa-text-main: #111b21;
  --wa-text-muted: #667781;
}

/* ================= 1. WIDGET CONTAINER ================= */
.wa-widget-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none; /* children enable pointer events */
}

/* Page with Sticky Bar clearance */
.wa-widget-wrap.has-sticky-bar {
  bottom: 84px;
}

/* ================= 2. LAUNCHER BUTTON & TOOLTIP ================= */
.wa-launcher-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

/* Tooltip Badge */
.wa-tooltip-pill {
  background: #ffffff;
  color: var(--wa-text-main);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transform-origin: right center;
  animation: waTooltipBounce 3s ease-in-out infinite;
  transition: opacity 0.25s ease, transform 0.25s ease;
  user-select: none;
}

.wa-tooltip-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}

.wa-tooltip-pill .wa-online-dot {
  width: 8px;
  height: 8px;
  background: var(--wa-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.35);
  animation: waPulseRing 2s infinite;
}

.wa-widget-wrap.chat-open .wa-tooltip-pill {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

/* Floating WhatsApp Circle Button */
.wa-launcher-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.42), 0 3px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.wa-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(37, 211, 102, 0.52), 0 4px 12px rgba(0, 0, 0, 0.14);
}

.wa-launcher-btn:active {
  transform: scale(0.96);
}

/* Subtle Pulsing Ambient Ring */
.wa-launcher-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.35);
  z-index: -1;
  animation: waPulseAmbient 2.6s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

.wa-widget-wrap.chat-open .wa-launcher-btn::before {
  display: none;
}

/* Notification counter badge */
.wa-badge-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff3b30;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.wa-widget-wrap.chat-open .wa-badge-unread {
  transform: scale(0);
  opacity: 0;
}

/* Icon Switching: WhatsApp vs Close */
.wa-launcher-btn .wa-icon-chat,
.wa-launcher-btn .wa-icon-close {
  position: absolute;
  width: 30px;
  height: 30px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  fill: currentColor;
}

.wa-launcher-btn .wa-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
  stroke: #ffffff;
  stroke-width: 2.5;
  width: 24px;
  height: 24px;
}

.wa-widget-wrap.chat-open .wa-launcher-btn .wa-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

.wa-widget-wrap.chat-open .wa-launcher-btn .wa-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ================= 3. CHAT POPUP WINDOW ================= */
.wa-chat-box {
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 470px;
  max-height: calc(100vh - 170px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  pointer-events: auto;
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.26s ease, visibility 0.26s;
}

.wa-widget-wrap.chat-open .wa-chat-box {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* Header */
.wa-chat-head {
  background: linear-gradient(135deg, var(--wa-teal) 0%, var(--wa-teal-deep) 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  flex-shrink: 0;
}

.wa-head-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-head-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.wa-head-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-head-avatar .wa-avatar-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f39316, #d97706);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.wa-avatar-online {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: var(--wa-green);
  border: 2px solid var(--wa-teal);
  border-radius: 50%;
}

.wa-head-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px 0;
  line-height: 1.2;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.wa-head-info p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wa-head-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.wa-head-close-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.08);
}

/* Chat Message Body */
.wa-chat-body {
  flex: 1;
  background-color: var(--wa-bg-chat);
  background-image: radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 0);
  background-size: 16px 16px;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Date Divider */
.wa-date-chip {
  align-self: center;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  color: var(--wa-text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  user-select: none;
}

/* Chat Message Bubble (Support Agent) */
.wa-msg-bubble {
  max-width: 86%;
  background: var(--wa-bubble-in);
  color: var(--wa-text-main);
  padding: 12px 14px 8px;
  border-radius: 0 14px 14px 14px;
  box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.08);
  position: relative;
  font-size: 13.5px;
  line-height: 1.48;
}

.wa-msg-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent var(--wa-bubble-in) transparent transparent;
}

.wa-msg-author {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--wa-teal);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wa-msg-text {
  margin-bottom: 6px;
}

.wa-msg-time {
  display: flex;
  justify-content: flex-end;
  font-size: 10px;
  color: var(--wa-text-muted);
  font-weight: 500;
}

/* Quick Prompt Action Chips */
.wa-prompt-chips {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wa-prompt-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--wa-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.wa-chip-btn {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--wa-text-main);
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wa-chip-btn:hover {
  background: #fdfaf4;
  border-color: var(--wa-green);
  color: var(--wa-teal);
  transform: translateX(3px);
}

.wa-chip-btn svg {
  width: 14px;
  height: 14px;
  color: var(--wa-green-dark);
  flex-shrink: 0;
}

/* Footer & Input Area */
.wa-chat-foot {
  background: #f0f2f5;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.wa-input-wrap {
  flex: 1;
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wa-input-wrap:focus-within {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
}

.wa-chat-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--wa-text-main);
  background: transparent;
  resize: none;
  max-height: 72px;
  line-height: 1.4;
  box-sizing: border-box;
}

.wa-chat-input::placeholder {
  color: #8e9ca3;
}

.wa-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s ease, background-color 0.2s ease;
  flex-shrink: 0;
}

.wa-send-btn:hover {
  background: var(--wa-green-dark);
  transform: scale(1.06);
}

.wa-send-btn:active {
  transform: scale(0.94);
}

.wa-send-btn svg {
  width: 18px;
  height: 18px;
  transform: translateX(1px);
}

/* Small WhatsApp Brand Footer inside chat */
.wa-brand-notice {
  font-size: 10.5px;
  color: var(--wa-text-muted);
  text-align: center;
  padding: 2px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.wa-brand-notice svg {
  width: 11px;
  height: 11px;
  fill: var(--wa-green);
}

/* ================= 4. SIDEBAR EMBEDDED BUTTON (FOR LEARNING PORTAL) ================= */
.sb-wa-doubt-box {
  margin: 14px 12px 6px;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.08) 0%, rgba(18, 140, 126, 0.12) 100%);
  border: 1px solid rgba(37, 211, 102, 0.28);
  border-radius: 12px;
  padding: 12px;
  transition: all 0.2s ease;
}

.sb-wa-doubt-box:hover {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.14) 0%, rgba(18, 140, 126, 0.18) 100%);
  border-color: var(--wa-green);
  transform: translateY(-1px);
}

.sb-wa-doubt-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.sb-wa-icon-circ {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

.sb-wa-icon-circ svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.sb-wa-text {
  flex: 1;
  min-width: 0;
}

.sb-wa-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #111b21;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.sb-wa-title .dot {
  width: 6px;
  height: 6px;
  background: var(--wa-green);
  border-radius: 50%;
  display: inline-block;
}

.sb-wa-desc {
  font-size: 11px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================= 5. ANIMATIONS ================= */
@keyframes waPulseAmbient {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes waPulseRing {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

@keyframes waTooltipBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ================= 6. MOBILE RESPONSIVENESS ================= */
@media (max-width: 640px) {
  .wa-widget-wrap {
    bottom: 20px;
    right: 16px;
  }

  .wa-widget-wrap.has-sticky-bar {
    bottom: 76px;
  }

  .wa-launcher-btn {
    width: 52px;
    height: 52px;
  }

  .wa-launcher-btn .wa-icon-chat {
    width: 27px;
    height: 27px;
  }

  .wa-tooltip-pill {
    display: none; /* Hide pill on very small screens to avoid cluttering */
  }

  .wa-chat-box {
    width: calc(100vw - 32px);
    height: 430px;
    max-height: calc(100vh - 160px);
    right: 0;
  }
}
