/* ============================================
   WhatsApp Chat Widget — Portal Bituach 2025
   ============================================ */

/* ---------- FAB Button ---------- */
#waWidget .wa-fab {
  position: fixed;
  bottom: 90px;
  left: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  z-index: 10001;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
  transition: all 0.3s ease;
}

#waWidget .wa-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

#waWidget .wa-fab .wa-close-icon {
  display: none;
}

#waWidget.wa-open .wa-fab .wa-wa-icon {
  display: none;
}

#waWidget.wa-open .wa-fab .wa-close-icon {
  display: inline;
  font-size: 1.4rem;
}

/* Pulse animation */
#waWidget .wa-fab::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.3);
  animation: waPulse 2s ease-out infinite;
  z-index: -1;
}

#waWidget.wa-open .wa-fab::after {
  animation: none;
}

@keyframes waPulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Notification badge */
#waWidget .wa-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

#waWidget.wa-open .wa-badge {
  display: none;
}

/* ---------- Chat Window ---------- */
#waWidget .wa-chat {
  position: fixed;
  bottom: 160px;
  left: 20px;
  width: 360px;
  max-height: 520px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  z-index: 10000;
  font-family: 'Heebo', Arial, sans-serif;
  background: #fff;
}

#waWidget.wa-open .wa-chat {
  display: flex;
  animation: waSlideUp 0.3s ease-out;
}

@keyframes waSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
#waWidget .wa-header {
  background: #075E54;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}

#waWidget .wa-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

#waWidget .wa-header-info {
  flex: 1;
  min-width: 0;
}

#waWidget .wa-header-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

#waWidget .wa-header-status {
  font-size: 0.78rem;
  opacity: 0.85;
}

#waWidget .wa-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#waWidget .wa-header-close:hover {
  opacity: 1;
}

/* Body */
#waWidget .wa-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='p' width='50' height='50' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='25' cy='25' r='1' fill='%23d4cec4' opacity='.3'/%3E%3C/pattern%3E%3C/defs%3E%3Crect fill='url(%23p)' width='400' height='400'/%3E%3C/svg%3E");
  min-height: 200px;
  max-height: 350px;
}

/* Messages */
#waWidget .wa-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}

#waWidget .wa-msg-in {
  background: #fff;
  border-top-right-radius: 0;
  margin-left: auto;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

#waWidget .wa-msg-out {
  background: #dcf8c6;
  border-top-left-radius: 0;
  margin-right: auto;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

#waWidget .wa-msg-time {
  font-size: 0.68rem;
  color: #999;
  text-align: left;
  margin-top: 4px;
}

/* Typing indicator */
#waWidget .wa-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 8px;
  border-top-right-radius: 0;
  margin-left: auto;
  width: fit-content;
  margin-bottom: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

#waWidget .wa-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: waTypingDot 1.4s ease-in-out infinite;
}

#waWidget .wa-typing span:nth-child(2) { animation-delay: 0.2s; }
#waWidget .wa-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes waTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Options Menu ---------- */
#waWidget .wa-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

#waWidget .wa-option-btn {
  background: #fff;
  border: 1.5px solid #25D366;
  color: #075E54;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
}

#waWidget .wa-option-btn:hover {
  background: #25D366;
  color: #fff;
}

#waWidget .wa-option-btn i {
  margin-left: 6px;
}

/* ---------- Lead Capture Form ---------- */
#waWidget .wa-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

#waWidget .wa-form input,
#waWidget .wa-form textarea {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#waWidget .wa-form input:focus,
#waWidget .wa-form textarea:focus {
  border-color: #25D366;
  outline: none;
}

#waWidget .wa-form textarea {
  resize: vertical;
  min-height: 60px;
}

#waWidget .wa-form-submit {
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

#waWidget .wa-form-submit:hover {
  background: #1da851;
}

#waWidget .wa-form-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#waWidget .wa-form-note {
  font-size: 0.75rem;
  color: #999;
  text-align: center;
}

/* ---------- Back Button ---------- */
#waWidget .wa-back {
  display: block;
  background: none;
  border: none;
  color: #075E54;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  margin-top: 6px;
  font-family: inherit;
  text-align: center;
  width: 100%;
}

#waWidget .wa-back:hover {
  text-decoration: underline;
}

/* ---------- Category Picker ---------- */
#waWidget .wa-cat-picker {
  max-height: 200px;
  overflow-y: auto;
}

#waWidget .wa-cat-picker .wa-option-btn {
  font-size: 0.82rem;
  padding: 6px 10px;
}

#waWidget .wa-option-back {
  opacity: 0.7;
  border-top: 1px solid #e5e5e5 !important;
  margin-top: 4px;
  padding-top: 8px !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #waWidget .wa-chat {
    left: 8px;
    right: 8px;
    bottom: 80px;
    width: auto;
    max-height: 70vh;
  }

  #waWidget .wa-fab {
    bottom: 76px;
    left: 14px;
    width: 54px;
    height: 54px;
    font-size: 1.5rem;
  }
}

@media (max-width: 380px) {
  #waWidget .wa-chat {
    border-radius: 12px;
  }

  #waWidget .wa-msg {
    max-width: 92%;
    font-size: 0.85rem;
  }
}

/* ---------- Exit-Intent Nudge ---------- */
#waWidget .wa-nudge {
  position: fixed;
  bottom: 160px;
  left: 20px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 10002;
  font-size: 0.9rem;
  max-width: 260px;
  display: none;
  animation: waNudge 0.5s ease-out;
  font-family: 'Heebo', Arial, sans-serif;
}

#waWidget .wa-nudge::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 30px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #fff;
}

#waWidget .wa-nudge-close {
  position: absolute;
  top: 4px;
  left: 8px;
  background: none;
  border: none;
  font-size: 1rem;
  color: #999;
  cursor: pointer;
  padding: 2px;
}

@keyframes waNudge {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  #waWidget .wa-nudge {
    left: 8px;
    right: 8px;
    bottom: 140px;
    max-width: none;
  }
}
