/* =====================================================
   FLOATING CHAT WIDGET STYLESHEET (ULTRA PREMIUM AESTHETICS)
   Path: css/components/floating-chat-widget.css
===================================================== */

/* -----------------------------------------------------
   0. CONTAINER OVERFLOW UNLOCK
----------------------------------------------------- */
#cta-whatsapp-container,
#floating-chat-placeholder,
#esi-chatbot {
  position: static !important;
  overflow: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* -----------------------------------------------------
   1. WHATSAPP FLOATING CTA BUTTON (Bottom Right)
----------------------------------------------------- */
.wa-icon {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  text-decoration: none !important;
  z-index: 99980 !important;
  visibility: visible !important;
  opacity: 1 !important;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wa-icon:hover {
  transform: translateY(-4px) scale(1.05) !important;
}

.wa-circle {
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  background: #25d366 !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.45) !important;
  border: 2px solid #ffffff !important;
  font-size: 30px !important;
  box-sizing: border-box !important;
  transition: box-shadow 0.3s ease !important;
}

.wa-icon:hover .wa-circle {
  box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6) !important;
}

.wa-text {
  background: #ffffff !important;
  color: #15803d !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  font-family: inherit !important;
  padding: 8px 16px !important;
  border-radius: 50px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
  border: 1px solid #dcfce7 !important;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.wa-icon:hover .wa-text {
  opacity: 1 !important;
  transform: translateX(0) !important;
}

/* -----------------------------------------------------
   2. ESI AI CHATBOT FAB (Stacked Vertically ABOVE WhatsApp Button)
----------------------------------------------------- */
#esi-chatbot {
  font-family: inherit;
}

@keyframes esiFabGlow {
  0% {
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.45), 0 0 0 0 rgba(37, 99, 235, 0.35);
  }
  70% {
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.45), 0 0 0 12px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.45), 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

#esi-fab {
  position: fixed !important;
  bottom: 96px !important;
  right: 24px !important;
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%) !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  animation: esiFabGlow 3s infinite !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 99990 !important;
  cursor: pointer !important;
  outline: none !important;
  visibility: visible !important;
  opacity: 1 !important;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease !important;
}

#esi-fab svg {
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  transition: transform 0.3s ease;
}

#esi-fab:hover {
  transform: translateY(-4px) scale(1.08) !important;
}

#esi-fab:hover svg {
  transform: rotate(12deg) scale(1.1);
}

#esi-fab.open {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
  animation: none !important;
}

#fab-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px #ef4444;
}

/* -----------------------------------------------------
   3. ESI AI CHATBOT POPUP WINDOW CARD
----------------------------------------------------- */
#esi-popup {
  position: fixed !important;
  bottom: 168px !important;
  right: 24px !important;
  width: 380px !important;
  max-width: calc(100vw - 32px) !important;
  height: 520px !important;
  max-height: calc(100vh - 270px) !important;
  border-radius: 22px !important;
  background: #ffffff !important;
  box-shadow: 0 25px 70px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(226, 232, 240, 0.8) !important;
  z-index: 99995 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.92);
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  box-sizing: border-box !important;
}

#esi-popup.visible {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
  display: flex !important;
}

/* Header Styling */
.esi-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%) !important;
  color: #ffffff !important;
  padding: 16px 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

.esi-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.esi-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.esi-header-name {
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.esi-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.88);
  margin-top: 3px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80;
  animation: esiPulse 2s infinite ease-in-out;
}

.esi-header-actions {
  display: flex;
  gap: 6px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: #ffffff !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: background 0.2s ease, transform 0.2s ease !important;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  transform: scale(1.08) !important;
}

/* Chat Body */
.esi-messages {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(203, 213, 225, 0.7) transparent;
}

.esi-messages::-webkit-scrollbar {
  width: 4px;
}

.esi-messages::-webkit-scrollbar-thumb {
  background: rgba(203, 213, 225, 0.7);
  border-radius: 10px;
}

.date-divider {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  margin: 2px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.bot-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.bubble {
  max-width: 84%;
  padding: 12px 18px;
  border-radius: 20px 20px 20px 4px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.875rem;
  line-height: 1.55;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  border: 1px solid #e2e8f0;
}

.msg-row.user {
  display: flex !important;
  justify-content: flex-end !important;
  width: 100% !important;
}

.user-msg-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  margin-left: auto !important;
  max-width: 84% !important;
}

.bubble.user-b {
  align-self: flex-end !important;
  width: fit-content !important;
  max-width: 100% !important;
  word-break: normal !important;
  white-space: pre-wrap !important;
  border-radius: 18px 18px 4px 18px !important;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25) !important;
  font-weight: 500 !important;
  padding: 10px 16px !important;
  letter-spacing: 0.1px !important;
}

.msg-meta {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
  font-weight: 500;
}

.msg-meta.user-m {
  text-align: right;
}

/* Visitor Email Prompt Card */
.email-bubble {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  padding: 14px 16px !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06) !important;
}

.email-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.email-copy {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 12px;
  line-height: 1.4;
}

.email-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.email-input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  font-size: 0.82rem;
  border-radius: 50px !important;
  border: 1px solid #cbd5e1;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.email-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.email-action {
  font-family: inherit;
  border-radius: 50px !important;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.email-action.primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 18px !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
}

.email-action.primary:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35) !important;
}

.email-action.secondary {
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: 1px solid #cbd5e1 !important;
  padding: 8px 14px !important;
}

.email-action.secondary:hover {
  background: #e2e8f0 !important;
  color: #334155 !important;
}

/* Typing Indicator Animation */
.typing-bubble {
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 18px 18px 18px 4px;
  border: 1px solid #e2e8f0;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
  animation: esiPulse 1.2s infinite ease-in-out;
}

.tdot:nth-child(2) {
  animation-delay: 0.2s;
}

.tdot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes esiPulse {
  0%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Quick Prompt Chips */
.quick-chips {
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  scrollbar-width: none;
}

.quick-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  background: #eff6ff !important;
  color: #2563eb !important;
  border: 1px solid #bfdbfe !important;
  padding: 7px 16px !important;
  border-radius: 50px !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  font-family: inherit;
}

.chip:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3) !important;
}

.chip.used {
  opacity: 0.75;
  cursor: pointer;
}

/* Input Row */
.esi-input-row {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.esi-input {
  flex: 1;
  border: 1px solid #cbd5e1 !important;
  border-radius: 50px !important;
  padding: 10px 18px !important;
  font-size: 0.86rem !important;
  outline: none !important;
  transition: all 0.2s ease !important;
  font-family: inherit;
  box-sizing: border-box;
}

.esi-input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15) !important;
}

.send-btn {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
  transition: all 0.25s ease !important;
}

.send-btn:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5) !important;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* -----------------------------------------------------
   6. RESPONSIVE MOBILE & TABLET STYLES
----------------------------------------------------- */

@media (max-width: 768px) {
  .wa-text {
    display: none !important; /* Hide text label on touch screens */
  }

  .wa-icon {
    position: fixed !important;
    bottom: 20px !important;
    right: 18px !important;
    z-index: 99980 !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .wa-circle {
    width: 52px !important;
    height: 52px !important;
    font-size: 26px !important;
  }

  #esi-fab {
    position: fixed !important;
    bottom: 84px !important;
    right: 18px !important;
    width: 52px !important;
    height: 52px !important;
    z-index: 99990 !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  #esi-fab i {
    font-size: 22px !important;
  }

  #esi-popup {
    position: fixed !important;
    top: 85px !important;
    bottom: 148px !important;
    right: 16px !important;
    left: 16px !important;
    width: auto !important;
    max-width: calc(100vw - 32px) !important;
    height: auto !important;
    max-height: calc(100vh - 233px) !important;
    z-index: 99995 !important;
  }
}

@media (max-width: 480px) {
  .wa-icon {
    position: fixed !important;
    bottom: 16px !important;
    right: 16px !important;
    z-index: 99980 !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .wa-circle {
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
  }

  #esi-fab {
    position: fixed !important;
    bottom: 76px !important;
    right: 16px !important;
    width: 48px !important;
    height: 48px !important;
    z-index: 99990 !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  #esi-fab i {
    font-size: 20px !important;
  }

  #esi-popup {
    position: fixed !important;
    top: 80px !important;
    bottom: 136px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    height: auto !important;
    max-height: calc(100vh - 216px) !important;
    border-radius: 18px !important;
    z-index: 99995 !important;
  }

  .esi-header {
    padding: 14px 16px !important;
  }

  .esi-messages {
    padding: 14px 12px !important;
  }
}
