/* Twin Rivers lead chat — shared widget */
/* Twin Rivers lead chat (Netlify) */
.lead-chat-nudge,
.lead-chat-toggle,
.lead-chat-backdrop,
.lead-chat-panel {
  --text: #e6e6e6;
  --bg-panel: #161a20;
  --bg-msg-bot: #1a1f2a;
  --bg-msg-user: #0d3d2a;
  --border: rgba(255, 255, 255, 0.08);
  --muted: #9ca3af;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.35);
  --glow-blue: rgba(56, 189, 248, 0.15);
  --radius: 14px;
  --shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  --bg-deep: #0a0c10;
}

.lead-chat-nudge {
  position: fixed;
  right: 1rem;
  bottom: 5.5rem;
  max-width: 220px;
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 24px var(--accent-dim);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 9997;
}
.lead-chat-nudge.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.lead-chat-nudge button {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bg-deep);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.lead-chat-nudge button:focus-visible {
  outline: 2px solid #86efac;
  outline-offset: 2px;
}

.lead-chat-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, #16a34a 0%, #22c55e 50%, #15803d 100%);
  color: #fff;
  box-shadow:
    0 6px 24px rgba(34, 197, 94, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.lead-chat-toggle:hover {
  transform: scale(1.06);
  box-shadow:
    0 8px 32px rgba(34, 197, 94, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}
.lead-chat-toggle:focus-visible {
  outline: 3px solid #86efac;
  outline-offset: 3px;
}
.lead-chat-toggle svg { width: 28px; height: 28px; }
.lead-chat-toggle[aria-expanded="true"] {
  background: linear-gradient(145deg, #334155 0%, #475569 100%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.lead-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 9995;
}
.lead-chat-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lead-chat-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(100vw - 2rem, 400px);
  max-height: min(560px, calc(100vh - 5.5rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow), 0 0 60px var(--glow-blue);
  z-index: 9996;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.lead-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.lead-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08) 0%, transparent 100%);
}
.lead-chat-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.lead-chat-header span {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: 0.15rem;
}
.lead-chat-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.lead-chat-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.lead-chat-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lead-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 220px;
  scroll-behavior: smooth;
}

.lead-chat-msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  animation: msgIn 0.4s ease forwards;
}
@keyframes msgIn {
  to { opacity: 1; transform: translateY(0); }
}
.lead-chat-msg--bot {
  align-self: flex-start;
  background: var(--bg-msg-bot);
  border: 1px solid var(--border);
  color: var(--text);
}
.lead-chat-msg--user {
  align-self: flex-end;
  background: var(--bg-msg-user);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #ecfdf5;
}
.lead-chat-msg--static {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

.lead-chat-typing {
  align-self: flex-start;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--bg-msg-bot);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.lead-chat-typing.is-visible { display: flex; }
.lead-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.lead-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.lead-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.lead-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 1rem 0.5rem;
}
.lead-chat-options[hidden] { display: none !important; }
.lead-chat-opt {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.lead-chat-opt:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 16px var(--accent-dim);
}
.lead-chat-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.lead-chat-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


.lead-chat-consent {
  margin: 0 1rem;
  padding: 0 0 0.65rem;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #9ca3af;
}

.lead-chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.lead-chat-input-row input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.lead-chat-input-row input::placeholder { color: #6b7280; }
.lead-chat-input-row input:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.lead-chat-input-row input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.lead-chat-send {
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--bg-deep);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s;
}
.lead-chat-send:hover:not(:disabled) { filter: brightness(1.08); }
.lead-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.lead-chat-send:focus-visible {
  outline: 2px solid #86efac;
  outline-offset: 2px;
}

.lead-chat-status {
  padding: 0 1rem 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.25rem;
}
.lead-chat-status--ok { color: #4ade80; }
.lead-chat-status--err { color: #f87171; }

@media (max-width: 480px) {
  .lead-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }
  .lead-chat-toggle { right: 0.75rem; bottom: 0.75rem; }
  .lead-chat-nudge { right: 0.75rem; bottom: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lead-chat-msg,
  .lead-chat-panel,
  .lead-chat-backdrop,
  .lead-chat-nudge {
    animation: none !important;
    transition: none !important;
  }
  .lead-chat-msg { opacity: 1; transform: none; }
  .lead-chat-typing span { animation: none; opacity: 0.6; }
}
