/* WhatsApp Widget Styles */
#whatsapp-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Floating Button */
.whatsapp-button {
  width: 60px;
  height: 60px;
  background: #25d366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
  transition: all 0.3s ease;
  position: relative;
  color: white;
}

.whatsapp-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Widget Base Styles */
.whatsapp-chat {
  position: fixed;
  bottom: 90px;
  right: 0;
  width: 350px;
  max-width: 350px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.whatsapp-chat.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  /* Updated to use WhatsApp's authentic teal color #128C7E */
  background: #128c7e;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: white;
}

.profile-details h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  /* Ensure Paul's name is white */
  color: white !important;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  opacity: 0.9;
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
}

.close-chat {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.close-chat:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Chat Body */
.chat-body {
  padding: 20px;
  background: #f0f0f0;
  min-height: 200px;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
}

.message-time {
  text-align: center;
  font-size: 12px;
  color: #666;
  margin-bottom: 16px;
}

.message-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Typing Indicator */
.typing-indicator {
  background: white;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  margin-bottom: 8px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Message Bubble */
.message-bubble {
  background: white;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  max-width: 280px;
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-text {
  font-size: 14px;
  margin-bottom: 8px;
  /* Make Hi there text dark instead of white for visibility */
  color: #333 !important;
}

.message-content {
  font-size: 14px;
  line-height: 1.4;
  color: #333;
}

/* Chat Footer */
.chat-footer {
  padding: 16px 20px;
  background: white;
  /* Removed border-top and powered-by section */
}

.input-container {
  display: flex;
  gap: 8px;
  /* Removed margin-bottom since powered-by section is gone */
}

#message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#message-input:focus {
  border-color: #25d366;
}

.send-button {
  width: 44px;
  height: 44px;
  background: #25d366;
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-button:hover {
  background: #128c7e;
}

/* Animation for widget entrance */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.whatsapp-widget-entrance {
  animation: slideInUp 0.5s ease-out;
}

/* ---------- Mobile: center popup above the button ---------- */
@media (max-width: 480px) {
  /* Using ID selector with higher specificity for mobile positioning */
  #whatsapp-chat {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important;
    transform-origin: bottom center !important;
    width: calc(100% - 28px) !important;
    max-width: 420px !important;
    border-radius: 12px !important;
    z-index: 10001 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translate(-50%, 12px) scale(0.98) !important;
    transition: opacity .28s cubic-bezier(0.4, 0, 0.2, 1), transform .28s cubic-bezier(0.4, 0, 0.2, 1), visibility .28s !important;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }

  /* Using ID selector for active state on mobile */
  #whatsapp-chat.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translate(-50%, 0) scale(1) !important;
  }

  /* Ensure message bubbles and body adapt */
  #whatsapp-chat .chat-body {
    padding: 14px;
    min-height: 160px;
  }

  #whatsapp-chat .message-bubble {
    max-width: 100%;
  }

  /* Slight tweaks for spacing */
  #whatsapp-widget {
    right: 16px;
    bottom: 16px;
  }
  .whatsapp-button {
    width: 54px;
    height: 54px;
  }
}
