/* ===========================================================
   EXCLUSIVE RECOVERY CENTERS — CHATBOT STYLES
   =========================================================== */

.erc-chat {
  --chat-green: #1a3a2e;
  --chat-green-dark: #0e2419;
  --chat-gold: #c9a961;
  --chat-cream: #f8f7f2;
  font-family: 'Outfit', -apple-system, sans-serif;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
}

/* ============================================
   LAUNCHER BUTTON
   ============================================ */
.erc-chat-launcher {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-green), var(--chat-green-dark));
  color: white;
  border: 3px solid var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(14, 36, 25, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  animation: chat-launcher-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 2s backwards;
}
.erc-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(201, 169, 97, 0.45);
}
.erc-chat-launcher:active {
  transform: scale(0.96);
}
.launcher-icon-chat {
  display: block;
}
.launcher-icon-close {
  display: none;
}
.erc-chat-launcher.chat-open .launcher-icon-chat {
  display: none;
}
.erc-chat-launcher.chat-open .launcher-icon-close {
  display: block;
}
.erc-chat-launcher.chat-open {
  background: var(--chat-green-dark);
  border-color: white;
}
.launcher-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--chat-gold);
  opacity: 0.35;
  animation: chat-pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.erc-chat-launcher.chat-open .launcher-pulse { display: none; }
.launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #b04545;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: badge-bounce 1s ease-out infinite;
}

@keyframes chat-launcher-in {
  from { transform: scale(0) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes chat-pulse {
  0% { transform: scale(1); opacity: 0.35; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes badge-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ============================================
   PROACTIVE PROMPT BUBBLE
   ============================================ */
.erc-chat-prompt {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 300px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(14, 36, 25, 0.18);
  padding: 18px 22px 18px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(20px) scale(0.92);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 3px solid var(--chat-gold);
}
.erc-chat-prompt.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.erc-chat-prompt::before {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 28px;
  width: 18px;
  height: 18px;
  background: white;
  transform: rotate(45deg);
  box-shadow: 4px 4px 8px rgba(14, 36, 25, 0.06);
}
.erc-chat-prompt-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-green), var(--chat-green-dark));
  color: var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
}
.erc-chat-prompt-body strong {
  display: block;
  font-size: 14px;
  color: var(--chat-green);
  margin-bottom: 4px;
}
.erc-chat-prompt-body p {
  font-size: 13px;
  color: #555;
  margin: 0 0 10px 0;
  line-height: 1.5;
}
.erc-chat-prompt-cta {
  background: var(--chat-green);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease;
}
.erc-chat-prompt-cta:hover {
  background: var(--chat-gold);
  color: var(--chat-green-dark);
}
.erc-chat-prompt-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.erc-chat-prompt-close:hover { color: #333; }

/* ============================================
   CHAT WINDOW
   ============================================ */
.erc-chat-window {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 30px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 18px;
  box-shadow: 0 25px 70px rgba(14, 36, 25, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.94);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 4px solid var(--chat-gold);
}
.erc-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* HEADER */
.erc-chat-header {
  background: linear-gradient(135deg, var(--chat-green), var(--chat-green-dark));
  color: white;
  padding: 18px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.erc-chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--chat-gold);
  color: var(--chat-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
}
.erc-chat-header-info { flex: 1; min-width: 0; }
.erc-chat-name {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.erc-chat-online {
  font-size: 10px;
  color: #6dd66d;
  font-weight: 400;
  letter-spacing: 0.5px;
}
.erc-chat-role {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}
.erc-chat-call,
.erc-chat-min {
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.erc-chat-call:hover,
.erc-chat-min:hover {
  background: rgba(255,255,255,0.22);
}
.erc-chat-min {
  font-size: 22px;
  line-height: 1;
  padding-bottom: 4px;
}

/* MESSAGES */
.erc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  background: linear-gradient(180deg, #fafaf6 0%, #f8f7f2 100%);
  scrollbar-width: thin;
  scrollbar-color: #d0c8b0 transparent;
}
.erc-chat-messages::-webkit-scrollbar { width: 6px; }
.erc-chat-messages::-webkit-scrollbar-thumb {
  background: #d0c8b0;
  border-radius: 3px;
}

.erc-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-end;
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.erc-msg-user {
  flex-direction: row-reverse;
}
.erc-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-green), var(--chat-green-dark));
  color: var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.erc-msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  color: #1a1a1a;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.erc-msg-agent .erc-msg-bubble {
  background: white;
  border-bottom-left-radius: 4px;
}
.erc-msg-user .erc-msg-bubble {
  background: var(--chat-green);
  color: white;
  border-bottom-right-radius: 4px;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* TYPING INDICATOR */
.erc-typing-bubble {
  padding: 14px 16px !important;
  display: flex;
  gap: 4px;
}
.erc-typing-bubble span {
  width: 7px;
  height: 7px;
  background: #aaa;
  border-radius: 50%;
  display: inline-block;
  animation: typing-dot 1.2s ease-in-out infinite;
}
.erc-typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.erc-typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* OPTION BUTTONS */
.erc-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px 40px;
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.erc-option {
  background: white;
  border: 1.5px solid #e5e1d6;
  color: var(--chat-green);
  padding: 11px 16px;
  border-radius: 22px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.2s ease;
  line-height: 1.4;
}
.erc-option:hover {
  background: var(--chat-green);
  color: white;
  border-color: var(--chat-green);
  transform: translateX(2px);
}

/* LEAD FORM */
.erc-lead-form {
  background: white;
  padding: 16px;
  border-radius: 14px;
  margin: 4px 0 12px 40px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 2px solid var(--chat-gold);
}
.erc-lead-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e5e1d6;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 8px;
  background: #fafaf6;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.erc-lead-form input:focus {
  outline: none;
  border-color: var(--chat-gold);
  background: white;
}
.erc-lead-form input.error {
  border-color: #b04545;
  background: #fef0f0;
  animation: shake 0.4s ease;
}
.erc-lead-submit {
  width: 100%;
  background: var(--chat-green);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease;
}
.erc-lead-submit:hover { background: var(--chat-gold); color: var(--chat-green-dark); }
.erc-lead-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.erc-lead-submit .arrow { transition: transform 0.2s ease; }
.erc-lead-submit:hover .arrow { transform: translateX(3px); }
.erc-lead-hipaa {
  text-align: center;
  font-size: 11px;
  color: #888;
  margin-top: 10px;
}
.erc-lead-submit .spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* FOOTER */
.erc-chat-footer {
  padding: 10px 18px;
  background: white;
  border-top: 1px solid #f0ece0;
}
.erc-chat-disclaimer {
  text-align: center;
  font-size: 11px;
  color: #888;
  letter-spacing: 0.3px;
}

/* MOBILE */
@media (max-width: 600px) {
  .erc-chat {
    bottom: 16px;
    right: 16px;
  }
  .erc-chat-window {
    bottom: 78px;
    right: -8px;
    width: calc(100vw - 16px);
    max-width: 400px;
    height: calc(100vh - 110px);
    max-height: 600px;
  }
  .erc-chat-prompt {
    width: calc(100vw - 80px);
    max-width: 300px;
  }
  /* When chat is open, hide the floating call button to avoid stacking */
  body.chat-open .floating-call { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .erc-chat-launcher,
  .launcher-pulse,
  .launcher-badge,
  .erc-typing-bubble span {
    animation: none !important;
  }
}
