/* Servefar — Lead Qualification Chatbot Widget */
:root {
  --sf-navy: #0B1B3D;
  --sf-navy-2: #04043D;
  --sf-gold: #D4A017;
  --sf-gold-2: #E5B800;
  --sf-bg: #FFFFFF;
  --sf-border: #EAEAEA;
  --sf-text: #1A1A1A;
  --sf-sub: #6B7280;
}

/* Floating button — sits 12px above the WhatsApp floating icon (bottom:24 + 56px + 12px = 92px) */
#sf-chat-launcher {
  position: fixed;
  bottom: 92px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--sf-navy);
  border: 1px solid var(--sf-border);
  box-shadow: 0 10px 30px rgba(11,27,61,0.14), 0 2px 10px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.22s cubic-bezier(0.16,1,0.3,1), box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s;
}
#sf-chat-launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 36px rgba(11,27,61,0.18), 0 4px 14px rgba(0,0,0,0.12); border-color: rgba(11,27,61,0.12); }
#sf-chat-launcher:active { transform: scale(0.97); }
#sf-chat-launcher svg { width: 26px; height: 26px; display: block; color: var(--sf-navy); }
#sf-chat-launcher.is-open { background: #FFFFFF; color: var(--sf-navy); border-color: var(--sf-border); box-shadow: 0 8px 24px rgba(11,27,61,0.12); }
#sf-chat-launcher.is-open svg { width: 20px; height: 20px; }
#sf-chat-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 13px;
  height: 13px;
  background: #22C55E;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18), 0 1px 6px rgba(34,197,94,0.35);
  animation: sf-pulse-green 2s infinite;
}
@keyframes sf-pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.42), 0 1px 6px rgba(34,197,94,0.35); }
  70% { box-shadow: 0 0 0 7px rgba(34,197,94,0), 0 1px 6px rgba(34,197,94,0.35); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0), 0 1px 6px rgba(34,197,94,0.35); }
}
#sf-chat-launcher.is-open #sf-chat-badge { display: none; }

.sf-chat-label {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #FFFFFF;
  border: 1px solid var(--sf-border);
  border-radius: 999px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-size: 0.70rem;
  font-weight: 800;
  color: var(--sf-navy);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(11,27,61,0.12), 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: none;
  letter-spacing: -0.01em;
}
.sf-chat-label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #FFFFFF;
  filter: drop-shadow(0 1px 0 var(--sf-border));
}
#sf-chat-launcher.is-open .sf-chat-label { display: none; }

/* Overlay card — 12px above launcher (92 + 60 + 12 = 164px) — compact: shrinks to content, grows to max */
#sf-chat-widget {
  position: fixed;
  bottom: 164px;
  right: 20px;
  width: 360px;
  height: auto;
  max-height: min(520px, calc(100vh - 110px));
  background: var(--sf-bg);
  border: 1px solid rgba(11,27,61,0.08);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11,27,61,0.2), 0 8px 20px rgba(0,0,0,0.08), 0 1px 0 rgba(255,255,255,0.6) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.36s cubic-bezier(0.16,1,0.3,1);
}
#sf-chat-widget.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* Header */
.sf-chat-header {
  background: linear-gradient(135deg, #0B1B3D 0%, #0f2552 55%, #0B1B3D 100%);
  color: #FAF8F5;
  padding: 14px 14px 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(212,160,23,0.18);
}
.sf-chat-header-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sf-chat-avatar {
  width: 36px; height: 36px; border-radius: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(212,160,23,0.28);
  display: flex; align-items: center; justify-content: center;
  color: var(--sf-gold);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.sf-chat-avatar svg { width: 18px; height: 18px; display: block; }
.sf-chat-title { font-family: 'Noto Sans Khmer', sans-serif; font-weight: 800; font-size: 0.92rem; line-height: 1; color: #FAF8F5; letter-spacing: -0.01em; }
.sf-chat-subtitle { font-family: 'Poppins', sans-serif; font-size: 0.66rem; color: rgba(250,248,245,0.68); margin-top: 3px; letter-spacing: 0.02em; }
.sf-chat-close {
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  color: #FAF8F5; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.sf-chat-close:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.2); }
.sf-chat-close:active { transform: scale(0.96); }
.sf-chat-close svg { width: 16px; height: 16px; display: block; }

/* Body — compact: only as tall as content, scrolls after max (enlarged to show 12 add-on chips) */
.sf-chat-body {
  flex: 0 1 auto;
  overflow-y: auto;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sf-bg);
  scrollbar-width: thin;
  min-height: 0;
  max-height: 420px;
}
.sf-chat-body::-webkit-scrollbar { width: 5px; }
.sf-chat-body::-webkit-scrollbar-thumb { background: rgba(11,27,61,0.12); border-radius: 99px; }

/* Bubbles */
.sf-msg { display: flex; gap: 8px; align-items: flex-end; width: 100%; max-width: 100%; }
.sf-msg--bot { align-self: flex-start; }
.sf-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.sf-bubble {
  max-width: 84%;
  width: fit-content;
  padding: 11px 14px;
  border-radius: 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.84rem;
  line-height: 1.55;
  box-shadow: 0 1px 8px rgba(11,27,61,0.06);
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  white-space: normal;
}
.sf-msg--bot .sf-bubble {
  background: #FFFFFF;
  border: 1px solid #EDEDED;
  color: var(--sf-text);
  border-bottom-left-radius: 6px;
}
.sf-msg--user .sf-bubble {
  background: linear-gradient(135deg, #0B1B3D 0%, #132a5c 100%);
  color: #FAF8F5;
  border: 1px solid rgba(212,160,23,0.18);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(11,27,61,0.18);
}

/* Chips */
.sf-chips { display: flex; flex-wrap: wrap; gap: 7px; padding-left: 2px; }
.sf-chip {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sf-navy);
  background: #FFFFFF;
  border: 1px solid #E8E8E8;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  line-height: 1.2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  white-space: nowrap;
  word-break: keep-all;
  hyphens: none;
}
.sf-chip:hover { border-color: rgba(212,160,23,0.45); background: rgba(212,160,23,0.09); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(212,160,23,0.12); }
.sf-chip:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.sf-chip:disabled { opacity: 0.6; }

/* Typing */
.sf-typing { display: inline-flex; gap: 4px; align-items: center; padding: 10px 12px; }
.sf-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--sf-gold); opacity: 0.7; animation: sf-bounce 1.1s infinite; }
.sf-typing span:nth-child(2) { animation-delay: 0.15s; }
.sf-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sf-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-4px); opacity: 1; } }

/* Lead form */
.sf-form { display: flex; flex-direction: column; gap: 10px; background: #FFFFFF; border: 1px solid #EDEDED; border-radius: 14px; padding: 13px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.sf-form label { font-family: 'Poppins', sans-serif; font-size: 0.7rem; font-weight: 800; color: var(--sf-navy); letter-spacing: 0.06em; text-transform: uppercase; }
.sf-form input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #E8E8E8; background: #FAF8F5;
  font-family: 'Poppins', sans-serif; font-size: 0.84rem; color: var(--sf-text);
  outline: none; transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.sf-form input:focus { border-color: rgba(212,160,23,0.55); box-shadow: 0 0 0 3px rgba(212,160,23,0.14); background: #FFFFFF; }
.sf-form input.is-invalid { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
.sf-field-error { font-family: 'Poppins', sans-serif; font-size: 0.7rem; color: #DC2626; margin-top: -6px; }
/* intl-tel-input: flag + dial code stays visible inside phone field (like contact form) */
.sf-form .iti { width: 100%; display: block; }
.sf-form .iti input { padding-left: 92px !important; }
.sf-form .iti__selected-country { background: #FFFFFF; border-right: 1px solid #E8E8E8; border-radius: 10px 0 0 10px; padding: 0 8px; }
.sf-form .iti__selected-dial-code { font-family: 'Poppins', sans-serif; font-size: 0.84rem; font-weight: 600; color: var(--sf-navy); }
.sf-form .iti__flag-container, .sf-form .iti__selected-country { height: 100%; }
.sf-btn-primary {
  width: 100%; padding: 12px 14px; border-radius: 999px;
  background: linear-gradient(135deg, #0B1B3D 0%, #132a5c 100%); color: #FAF8F5;
  border: 1px solid rgba(212,160,23,0.28);
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 0.84rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s, background 0.2s;
  box-shadow: 0 4px 14px rgba(11,27,61,0.18);
}
.sf-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(11,27,61,0.24); }
.sf-btn-primary:active { transform: translateY(0); }
.sf-btn-primary svg { width: 16px; height: 16px; display: block; flex-shrink: 0; }
.sf-btn-whatsapp {
  width: 100%; padding: 11px 14px; border-radius: 999px;
  background: #25D366; color: #0B1B3D; border: 1px solid rgba(0,0,0,0.06);
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 0.82rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; cursor: pointer; box-shadow: 0 4px 14px rgba(37,211,102,0.22);
  transition: transform 0.18s, box-shadow 0.18s;
}
.sf-btn-whatsapp:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(37,211,102,0.28); }
.sf-btn-whatsapp svg { width: 18px; height: 18px; display: block; }
.sf-btn-ghost {
  width: 100%; padding: 9px 14px; border-radius: 999px;
  background: #FFFFFF; color: var(--sf-navy); border: 1px solid #E8E8E8;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 0.78rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color 0.18s, background 0.18s;
}
.sf-btn-ghost:hover { border-color: rgba(11,27,61,0.18); background: #FAF8F5; }
.sf-form-hint { font-family: 'Poppins', sans-serif; font-size: 0.7rem; color: var(--sf-sub); line-height: 1.4; }
.sf-success { text-align: center; padding: 6px 2px; }
.sf-success-icon { width: 54px; height: 54px; border-radius: 50%; background: #0B1B3D; color: #22C55E; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #0B1B3D; box-shadow: 0 6px 18px rgba(11,27,61,0.18); flex-shrink: 0; }
.sf-success-icon svg { width: 26px; height: 26px; display: block; }

/* Footer */
.sf-chat-footer { padding: 8px 12px 10px; border-top: 1px solid var(--sf-border); background: #FFFFFF; flex-shrink: 0; }
.sf-chat-footer small { font-family: 'Poppins', sans-serif; font-size: 0.64rem; color: var(--sf-sub); display: block; text-align: center; }

/* Mobile — WhatsApp below chatbot, perfectly aligned column — compact */
@media (max-width: 480px) {
  /* Stack: chatbot (top) → WhatsApp (bottom), same X-axis, no scale distortion */
  .floating-contact {
    right: 14px !important;
    bottom: 14px !important;
    gap: 10px !important;
    transform: none !important;
  }
  .floating-contact a {
    width: 56px !important;
    height: 56px !important;
    font-size: 1.4rem !important;
  }
  #sf-chat-launcher { right: 14px; bottom: 82px; width: 56px; height: 56px; }
  #sf-chat-widget { right: 10px; left: 10px; width: auto; height: auto; bottom: 154px; max-height: min(560px, calc(100vh - 100px)); }
  .sf-chat-body { max-height: min(50vh, 400px); }
  .sf-chat-header { padding: 16px 14px 12px 16px; }
  .sf-chat-header-left { gap: 10px; }
  .sf-chat-avatar { width: 32px; height: 32px; border-radius: 10px; }
  .sf-chat-title { font-size: 0.88rem; line-height: 1.15; }
  .sf-chat-subtitle { font-size: 0.60rem; line-height: 1.4; margin-top: 2px; }
  .sf-chat-body { padding: 14px 12px 10px; gap: 10px; }
  .sf-bubble { font-size: 0.82rem; padding: 10px 12px; }
  .sf-chip { font-size: 0.74rem; padding: 7px 11px; }
  .sf-chat-label { font-size: 0.64rem; padding: 5px 9px; bottom: calc(100% + 8px); }
}
