/* IMFIT Chat Assistant & Conversational Lead Widget */
:root {
  --chat-navy: #10243b;
  --chat-surface: #0e1b2b;
  --chat-bubble-bot: #16273c;
  --chat-bubble-user: #e7a722;
  --chat-text: #f6f5f0;
  --chat-muted: #94a3b8;
  --chat-gold: #e7a722;
  --chat-gold-glow: rgba(231, 167, 34, 0.25);
  --chat-line: rgba(255, 255, 255, 0.1);
}

/* Floating Launcher Button */
#imfit-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-navy);
  border: 2px solid var(--chat-gold);
  color: #fff;
  box-shadow: 0 8px 24px rgba(16, 36, 59, 0.45), 0 0 16px var(--chat-gold-glow);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

#imfit-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 32px rgba(16, 36, 59, 0.6), 0 0 24px rgba(231, 167, 34, 0.4);
}

#imfit-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Unread Badge / Pulse */
.chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--chat-gold);
  border: 2px solid var(--chat-navy);
  animation: chat-pulse 2s infinite;
}

@keyframes chat-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 167, 34, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(231, 167, 34, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 167, 34, 0); }
}

/* Floating Teaser Bubble */
#imfit-chat-teaser {
  position: fixed;
  bottom: 34px;
  right: 100px;
  z-index: 998;
  background: #ffffff;
  color: var(--chat-navy);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(231, 167, 34, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  animation: chat-fade-in 0.4s ease both;
  white-space: nowrap;
}

#imfit-chat-teaser button {
  background: transparent;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: #94a3b8;
  padding: 0;
  margin-left: 4px;
  cursor: pointer;
}

#imfit-chat-teaser button:hover {
  color: var(--chat-navy);
}

/* Chat Modal / Popup Window */
#imfit-chat-modal {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--chat-surface);
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 20px rgba(16, 36, 59, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  visibility: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
}

#imfit-chat-modal.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.chat-header {
  padding: 16px 20px;
  background: var(--chat-navy);
  border-bottom: 1px solid var(--chat-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0b1725;
  border: 1.5px solid var(--chat-gold);
  display: grid;
  place-items: center;
  font-family: var(--display, sans-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--chat-gold);
  flex-shrink: 0;
}

.chat-header-titles {
  display: flex;
  flex-direction: column;
}

.chat-header-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.chat-header-status {
  font-size: 11px;
  color: var(--chat-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.chat-header-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Chat Messages Stream */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.chat-msg {
  max-width: 86%;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 16px;
  word-break: break-word;
  animation: chat-fade-in 0.25s ease both;
}

@keyframes chat-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-bot {
  align-self: flex-start;
  background: var(--chat-bubble-bot);
  color: var(--chat-text);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top-left-radius: 4px;
}

.chat-msg-bot p + p {
  margin-top: 8px;
}

.chat-msg-bot strong {
  color: var(--chat-gold);
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--chat-bubble-user);
  color: var(--chat-navy);
  font-weight: 600;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(231, 167, 34, 0.2);
}

/* Typing Indicator */
.chat-typing {
  align-self: flex-start;
  background: var(--chat-bubble-bot);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: chat-bounce 1.3s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes chat-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Action Chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  animation: chat-fade-in 0.3s ease both;
}

.chat-chip {
  background: rgba(231, 167, 34, 0.08);
  border: 1px solid rgba(231, 167, 34, 0.35);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  line-height: 1.3;
}

.chat-chip:hover,
.chat-chip:focus-visible {
  background: var(--chat-gold);
  color: var(--chat-navy);
  border-color: var(--chat-gold);
  transform: translateY(-1px);
}

/* Inline Interactive Lead / Demo Booking Card */
.chat-form-card {
  align-self: flex-start;
  width: 100%;
  background: #112033;
  border: 1px solid rgba(231, 167, 34, 0.35);
  border-radius: 14px;
  padding: 16px;
  color: #fff;
  margin-top: 4px;
}

.chat-form-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--chat-gold);
  font-weight: 700;
}

.chat-form-card p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--chat-muted);
  line-height: 1.4;
}

.chat-form-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-field label {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-field input {
  background: #08111d;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.chat-field input:focus {
  border-color: var(--chat-gold);
}

.chat-field-hint {
  font-size: 10px;
  color: var(--chat-muted);
}

.chat-form-submit {
  margin-top: 8px;
  background: var(--chat-gold);
  color: var(--chat-navy);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.18s, transform 0.18s;
}

.chat-form-submit:hover {
  background: #f2b737;
  transform: translateY(-1px);
}

.chat-form-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.chat-form-error {
  margin-top: 8px;
  font-size: 11px;
  color: #f87171;
}

/* Success Card */
.chat-success-card {
  align-self: flex-start;
  width: 100%;
  background: #0b1e17;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 14px;
  padding: 16px;
  color: #fff;
}

.chat-success-card h4 {
  margin: 0 0 6px;
  color: #4ade80;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-success-card p {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #d1fae5;
}

.chat-success-wa {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25d366;
  color: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  margin-top: 6px;
}

.chat-success-wa:hover {
  background: #1ebe5d;
  color: #fff;
}

/* Input Bar */
.chat-input-bar {
  padding: 12px 14px;
  background: var(--chat-navy);
  border-top: 1px solid var(--chat-line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  background: #08111d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  color: #fff;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--chat-gold);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-gold);
  border: none;
  color: var(--chat-navy);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.18s, background 0.18s;
}

.chat-send-btn:hover {
  transform: scale(1.06);
  background: #f2b737;
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Standalone / Full-Page Mode (for /chat) */
.chat-fullscreen-page {
  min-height: calc(100vh - 96px);
  padding: 24px 0 48px;
  display: flex;
  flex-direction: column;
}

.chat-fullscreen-container {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  height: calc(100vh - 160px);
  min-height: 580px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.chat-fullscreen-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chat-ad-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--chat-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-wa-direct {
  font-size: 12px;
  font-weight: 600;
  color: #25d366;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
  #imfit-chat-launcher {
    bottom: 82px; /* Clears mobile bar */
    right: 18px;
    width: 54px;
    height: 54px;
  }

  #imfit-chat-teaser {
    display: none; /* Keep mobile clean */
  }

  #imfit-chat-modal {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: calc(100dvh - 56px);
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }

  .chat-fullscreen-page {
    padding: 0;
  }

  .chat-fullscreen-container {
    height: calc(100dvh - 80px);
    border-radius: 0;
    border: none;
  }
}
