/* =======================================================
   Base Container & Device Visibility
======================================================= */
.waply-widget-container {
  position: fixed;
  bottom: 30px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (min-width: 1025px) {
  .waply-hide-desktop {
    display: none !important;
  }
}
@media (min-width: 768px) and (max-width: 1024px) {
  .waply-hide-tablet {
    display: none !important;
  }
}
@media (max-width: 767px) {
  .waply-hide-mobile {
    display: none !important;
  }
}

/* Positioning */
.waply-pos-right {
  right: 30px;
}
.waply-pos-left {
  left: 30px;
}
.waply-pos-right .waply-popup-window {
  right: 0;
  transform-origin: bottom right;
}
.waply-pos-left .waply-popup-window {
  left: 0;
  transform-origin: bottom left;
}

/* =======================================================
   Button Sizes
======================================================= */
.waply-trigger-btn {
  border-radius: 50%;
  border: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  padding: 0;
}

.waply-trigger-btn img {
  width: 60%;
  height: 60%;
  object-fit: contain;
}

.waply-size-small .waply-trigger-btn {
  width: 44px;
  height: 44px;
}
.waply-size-small .waply-trigger-btn svg {
  width: 24px;
  height: 24px;
}
.waply-size-medium .waply-trigger-btn {
  width: 54px;
  height: 54px;
}
.waply-size-medium .waply-trigger-btn svg {
  width: 32px;
  height: 32px;
}
.waply-size-large .waply-trigger-btn {
  width: 64px;
  height: 64px;
}
.waply-size-large .waply-trigger-btn svg {
  width: 40px;
  height: 40px;
}

/* =======================================================
   Popup Window
======================================================= */
.waply-popup-window {
  position: absolute;
  bottom: calc(100% + 15px);
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.waply-popup-window.waply-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Header */
.waply-header {
  padding: 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.waply-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.waply-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}
.waply-user-info {
  display: flex;
  flex-direction: column;
}
.waply-user-info strong {
  font-size: 15px;
  line-height: 1.2;
}
.waply-user-info span {
  font-size: 12px;
  opacity: 0.9;
}

#waply-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}
#waply-close-btn:hover {
  opacity: 1;
}

/* Body */
/* Body with Inline SVG WhatsApp Doodle Pattern */
.waply-body {
  padding: 20px;
  background-color: #e5ddd5; /* Classic WA Beige */

  /* Lightweight Inline SVG Doodle Pattern */
  background-image: url('data:image/svg+xml;utf8,<svg width="150" height="150" viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%23000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><g opacity="0.06"><path d="M30 40c-4 0-7-3-7-7s3-7 7-7c1-4 5-6 9-4 4-2 8 0 9 4 4 0 7 3 7 7s-3 7-7 7H30z"/><path d="M110 110h15a5 5 0 0 0 5-5V90a5 5 0 0 0-5-5h-15a5 5 0 0 0-5 5v15c0 2 1 4 3 5l-3 5 5-5z"/><path d="M120 30l3-6 3 6 6 1-4 4 1 6-5-3-5 3 1-6-4-4z"/><path d="M40 110V95a5 5 0 0 1 10 0v15m-10-15h10"/><circle cx="37" cy="110" r="3"/><circle cx="47" cy="110" r="3"/><path d="M70 70l6-6m0 6l-6-6"/><path d="M130 70l6-6m0 6l-6-6"/><circle cx="85" cy="20" r="1.5"/><circle cx="50" cy="130" r="1.5"/><path d="M15 80a6 6 0 1 0 0-12 6 6 0 0 0 0 12z"/><path d="M90 135s-3-5 0-8 8-3 8 0 3 8 0 8-8 3-8 0z"/><path d="M75 95c-3 0-5-2-5-5v-10c0-3 2-5 5-5h10c3 0 5 2 5 5v10c0 3-2 5-5 5H75zm0-20v20m10-20v20m-10-10h10"/><path d="M135 45a4 4 0 0 1-4-4 4 4 0 0 1 4-4 4 4 0 0 1 4 4 4 4 0 0 1-4 4z"/><path d="M20 20l4-4 4 4-4 4-4-4z"/></g></svg>');
  background-repeat: repeat;
  background-size: 150px;
  min-height: 150px;
}

/* Ensure Dark Mode adapts to the SVG */
.waply-theme-dark .waply-body {
  background-color: #0b141a;
}

.waply-message-bubble {
  background: white;
  padding: 12px 20px 3px 16px;
  border-radius: 0 12px 12px 12px;
  font-size: 14px;
  color: #333;
  display: inline-block;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  min-width: 60px;
  min-height: 38px; /* Prevents jumping when loader hides */
}

/* Footer */
.waply-footer {
  padding: 15px;
  background: #fff;
  text-align: center;
}

.waply-start-chat-btn {
  display: inline-block; /* Fixed from block to inline-block for better SVG alignment */
  color: white;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 15px;
  transition: filter 0.2s;
  width: 70%;
}
.waply-start-chat-btn:hover {
  filter: brightness(1.1);
}

/* =======================================================
   Animations (Loader & Idle)
======================================================= */
.waply-typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.waply-typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: #888;
  border-radius: 50%;
  animation: waplyBlink 1.4s infinite both;
}
.waply-typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.waply-typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes waplyBlink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

/* Idle Animations */
.waply-anim-pulse .waply-trigger-btn {
  animation: waplyPulse 2s infinite;
}
@keyframes waplyPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

.waply-anim-bounce .waply-trigger-btn {
  animation: waplyBounce 2s infinite;
}
@keyframes waplyBounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-7px);
  }
}

.waply-anim-shake .waply-trigger-btn {
  animation: waplyShake 2.5s infinite;
}
@keyframes waplyShake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-4px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(4px);
  }
}

.waply-anim-swing .waply-trigger-btn {
  transform-origin: top center;
  animation: waplySwing 3s infinite;
}
@keyframes waplySwing {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(15deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
  }
  80% {
    transform: rotate(-5deg);
  }
}

.waply-anim-tada .waply-trigger-btn {
  animation: waplyTada 3s infinite;
}
@keyframes waplyTada {
  0%,
  100% {
    transform: scale(1);
  }
  10%,
  20% {
    transform: scale(0.9) rotate(-3deg);
  }
  30%,
  50%,
  70%,
  90% {
    transform: scale(1.1) rotate(3deg);
  }
  40%,
  60%,
  80% {
    transform: scale(1.1) rotate(-3deg);
  }
}

.waply-anim-heartbeat .waply-trigger-btn {
  animation: waplyHeartbeat 2s infinite;
}
@keyframes waplyHeartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.15);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.15);
  }
  70% {
    transform: scale(1);
  }
}

.waply-anim-float .waply-trigger-btn {
  animation: waplyFloat 3s ease-in-out infinite;
}
@keyframes waplyFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.waply-anim-wobble .waply-trigger-btn {
  animation: waplyWobble 3s infinite;
}
@keyframes waplyWobble {
  0%,
  100% {
    transform: translateX(0%);
  }
  15% {
    transform: translateX(-15%) rotate(-5deg);
  }
  30% {
    transform: translateX(10%) rotate(3deg);
  }
  45% {
    transform: translateX(-10%) rotate(-3deg);
  }
  60% {
    transform: translateX(5%) rotate(2deg);
  }
  75% {
    transform: translateX(-2%) rotate(-1deg);
  }
}

/* =======================================================
   Loaders
======================================================= */
.waply-loader-spinner .waply-typing-indicator,
.waply-loader-pulse .waply-typing-indicator,
.waply-loader-wave .waply-typing-indicator,
.waply-loader-flash .waply-typing-indicator,
.waply-loader-expand .waply-typing-indicator,
.waply-loader-cursor .waply-typing-indicator {
  display: none !important;
}

.waply-loader-spinner::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #999;
  border-radius: 50%;
  animation: waplySpin 1s linear infinite;
}
@keyframes waplySpin {
  to {
    transform: rotate(360deg);
  }
}

.waply-loader-pulse::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  background-color: #999;
  border-radius: 50%;
  animation: waplyPulseAnim 1.5s infinite ease-in-out;
}
@keyframes waplyPulseAnim {
  0%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.waply-loader-wave {
  display: flex;
  gap: 4px;
  height: 20px;
  background: repeating-linear-gradient(90deg, #999 0, #999 4px, transparent 4px, transparent 8px);
  width: 20px;
  animation: waplyWave 1s infinite alternate;
}
@keyframes waplyWave {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}

.waply-loader-cursor::before {
  content: "";
  display: block;
  width: 12px;
  height: 20px;
  background-color: #999;
  animation: waplyCursor 1s step-end infinite;
}
@keyframes waplyCursor {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.waply-loader-expand::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid #999;
  border-radius: 50%;
  animation: waplyExpand 1.5s infinite ease-out;
}
@keyframes waplyExpand {
  0% {
    transform: scale(0.1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* =======================================================
   Themes
======================================================= */
.waply-theme-dark .waply-body {
  background: #1a1a1a;
}
.waply-theme-dark .waply-message-bubble {
  background: #333;
  color: #eee;
}
.waply-theme-dark .waply-popup-window {
  background: #222;
}
.waply-theme-material .waply-popup-window {
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.19),
    0 6px 6px rgba(0, 0, 0, 0.23);
  border-radius: 4px;
}
.waply-theme-material .waply-trigger-btn {
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19);
}
.waply-theme-bubble .waply-popup-window {
  border-radius: 24px;
}
.waply-theme-bubble .waply-message-bubble {
  border-radius: 20px 20px 20px 4px;
}
.waply-theme-glass .waply-popup-window {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.waply-theme-glass .waply-header,
.waply-theme-glass .waply-footer {
  background: transparent !important;
}
.waply-theme-glass .waply-header {
  color: #333;
}
.waply-theme-glass #waply-close-btn {
  color: #333;
}
.waply-theme-glass .waply-body {
  background: transparent;
}
.waply-theme-glass .waply-message-bubble {
  background: rgba(255, 255, 255, 0.8);
}
.waply-theme-neo-brutal .waply-popup-window {
  border: 4px solid #000;
  box-shadow: 8px 8px 0px #000;
  border-radius: 0;
}
.waply-theme-neo-brutal .waply-trigger-btn {
  border: 4px solid #000;
  box-shadow: 6px 6px 0px #000;
}
.waply-theme-neo-brutal .waply-message-bubble {
  border: 2px solid #000;
  border-radius: 0;
  box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
}
.waply-theme-neo-brutal .waply-start-chat-btn {
  border: 2px solid #000;
  border-radius: 0;
}
.waply-theme-gradient .waply-header {
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0.1) 100%);
}
.waply-theme-gradient .waply-trigger-btn {
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(0, 0, 0, 0.1) 100%);
}
.waply-theme-minimal .waply-popup-window {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid #eaeaea;
}
.waply-theme-minimal .waply-body {
  background: #fafafa;
}
.waply-theme-minimal .waply-message-bubble {
  box-shadow: none;
  border: 1px solid #eaeaea;
}
.waply-theme-minimal .waply-header {
  padding: 15px 20px;
}
.waply-theme-neumorphic .waply-popup-window {
  background: #e0e5ec;
  box-shadow:
    9px 9px 16px rgba(163, 177, 198, 0.6),
    -9px -9px 16px rgba(255, 255, 255, 0.5);
  border: none;
}
.waply-theme-neumorphic .waply-header,
.waply-theme-neumorphic .waply-footer,
.waply-theme-neumorphic .waply-body {
  background: transparent !important;
  color: #333;
}
.waply-theme-neumorphic #waply-close-btn {
  color: #333;
}
.waply-theme-neumorphic .waply-message-bubble {
  background: #e0e5ec;
  box-shadow:
    inset 6px 6px 10px 0 rgba(163, 177, 198, 0.5),
    inset -6px -6px 10px 0 rgba(255, 255, 255, 0.8);
}
