/* ==========================================================================
   Standalone WhatsApp Chat Widget Stylesheet (.wa-*)
   Zero-dependency, responsive, drop-in click-to-chat widget
   ========================================================================== */

:root {
  --wa-brand: #25D366;
  --wa-brand-dark: #128C7E;
  --wa-header-bg: #075E54;
  --wa-chat-bg: #efe7dd;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-text-dark: #111b21;
  --wa-text-muted: #667781;
  --wa-shadow: 0 12px 36px rgba(11, 20, 26, 0.22);
  --wa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base reset for widget namespace */
.wa-widget-container * {
  box-sizing: border-box;
  font-family: var(--wa-font);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

.wa-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none; /* Allow clicking through container */
}

/* Bottom-left positioning override */
.wa-widget-container.wa-pos-left {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

/* ==========================================================================
   Launcher Button
   ========================================================================== */
.wa-launcher {
  pointer-events: auto;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--wa-brand);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
  position: relative;
}

.wa-launcher:hover {
  transform: scale(1.08);
  background-color: var(--wa-brand-dark);
}

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

.wa-launcher svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

/* Pulse animation ring */
.wa-launcher::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--wa-brand);
  opacity: 0;
  animation: wa-pulse 2.5s infinite ease-out;
}

@keyframes wa-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* Notification badge */
.wa-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: #ff3b30;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  animation: wa-bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes wa-bounce {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   Chat Popup Window
   ========================================================================== */
.wa-chat-box {
  pointer-events: auto;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 100px);
  background-color: var(--wa-chat-bg);
  border-radius: 16px;
  box-shadow: var(--wa-shadow);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  visibility: hidden;
}

.wa-pos-left .wa-chat-box {
  transform-origin: bottom left;
}

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

/* Header */
.wa-header {
  background: linear-gradient(135deg, var(--wa-header-bg), var(--wa-brand-dark));
  color: #ffffff;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

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

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

.wa-avatar svg {
  width: 26px;
  height: 26px;
  fill: var(--wa-header-bg);
}

.wa-header-info {
  flex-grow: 1;
  min-width: 0;
}

.wa-header-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.wa-header-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wa-status-dot {
  width: 8px;
  height: 8px;
  background-color: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 6px #4ade80;
}

.wa-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}

.wa-close:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.wa-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Chat Body (Conversation area) */
.wa-body {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
  background-image: radial-gradient(#d3c8bc 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Timestamp header */
.wa-date {
  align-self: center;
  background-color: rgba(255, 255, 255, 0.85);
  color: var(--wa-text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  margin-bottom: 4px;
}

/* Chat Bubble */
.wa-bubble {
  align-self: flex-start;
  background-color: var(--wa-bubble-in);
  color: var(--wa-text-dark);
  padding: 10px 14px;
  border-radius: 0 12px 12px 12px;
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  font-size: 14px;
  line-height: 1.4;
  animation: wa-slide-in 0.3s ease-out;
}

@keyframes wa-slide-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.wa-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--wa-text-muted);
}

/* Quick Replies Chips */
.wa-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.wa-quick-replies-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--wa-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wa-chip {
  background-color: #ffffff;
  border: 1px solid rgba(37, 211, 102, 0.4);
  color: var(--wa-brand-dark);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wa-chip:hover {
  background-color: #f0fdf4;
  border-color: var(--wa-brand);
  transform: translateX(3px);
  box-shadow: 0 4px 8px rgba(37, 211, 102, 0.15);
}

/* Footer / Input Area */
.wa-footer {
  background-color: #f0f2f5;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-input {
  flex-grow: 1;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--wa-text-dark);
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
}

.wa-input:focus {
  border-color: var(--wa-brand);
}

.wa-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--wa-brand);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, background-color 0.2s;
}

.wa-send-btn:hover {
  background-color: var(--wa-brand-dark);
  transform: scale(1.05);
}

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

.wa-send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: 2px; /* Slight visual centering tweak */
}

/* Responsive adjustment for small screens */
@media (max-width: 480px) {
  .wa-widget-container {
    bottom: 16px;
    right: 16px;
  }
  
  .wa-widget-container.wa-pos-left {
    left: 16px;
  }
  
  .wa-chat-box {
    width: calc(100vw - 32px);
    height: 450px;
  }
}
