/* Solarnova chat widget — mobile-safe, no content overlap.
   Sits above the existing floating call button + cookie banner on mobile. */

.sn-chat {
  --sn-primary: #0a1628;
  --sn-accent: #f97316;          /* site brand orange */
  --sn-accent-hover: #ea580c;
  --sn-bg: #ffffff;
  --sn-user: #0a1628;
  --sn-bot: #f1f5f9;
  --sn-text: #111827;
  --sn-muted: #6b7280;
  --sn-border: #e5e7eb;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---------- Launcher ---------- */
.sn-launcher {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 2147483000;           /* above everything incl. sticky/floating bars */
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--sn-accent);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.45);
  transition: transform 180ms ease, background 180ms ease;
}
.sn-launcher:hover { background: var(--sn-accent-hover); transform: scale(1.06); }
.sn-launcher:focus-visible { outline: 3px solid rgba(249, 115, 22, 0.5); outline-offset: 2px; }
.sn-launcher.sn-pulse { animation: sn-pulse 2.2s ease-out 3; }
@keyframes sn-pulse {
  0%   { box-shadow: 0 8px 24px rgba(249,115,22,0.45), 0 0 0 0 rgba(249,115,22,0.55); }
  70%  { box-shadow: 0 8px 24px rgba(249,115,22,0.45), 0 0 0 16px rgba(249,115,22,0); }
  100% { box-shadow: 0 8px 24px rgba(249,115,22,0.45), 0 0 0 0 rgba(249,115,22,0); }
}
.sn-launcher .sn-close-icon { display: none; }
.sn-chat.sn-is-open .sn-launcher .sn-open-icon { display: none; }
.sn-chat.sn-is-open .sn-launcher .sn-close-icon { display: block; }

/* Hide launcher entirely while the fullscreen panel is open on mobile. */
@media (max-width: 768px) {
  .sn-launcher {
    bottom: calc(86px + env(safe-area-inset-bottom));   /* above the floating call button */
    right: 14px;
  }
  .sn-chat.sn-is-open .sn-launcher { display: none; }
}

/* ---------- Panel ---------- */
.sn-panel {
  position: fixed;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--sn-bg);
  border: 1px solid var(--sn-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.sn-chat.sn-is-open .sn-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.sn-panel[hidden] { display: none; }

/* Header */
.sn-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--sn-primary);
  color: #fff;
}
.sn-header .sn-logo {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sn-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex: 0 0 auto;
}
.sn-header .sn-titles { line-height: 1.2; flex: 1 1 auto; min-width: 0; }
.sn-header .sn-title { font-weight: 700; font-size: 0.95rem; }
.sn-header .sn-subtitle { font-size: 0.72rem; opacity: 0.75; }
.sn-header .sn-x {
  background: transparent; border: none; color: #fff; cursor: pointer;
  font-size: 20px; width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.sn-header .sn-x:hover { background: rgba(255,255,255,0.12); }

/* Message list */
.sn-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sn-bg);
  -webkit-overflow-scrolling: touch;
}
.sn-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sn-bubble.sn-bot {
  align-self: flex-start;
  background: var(--sn-bot);
  color: var(--sn-text);
  border-bottom-left-radius: 4px;
}
.sn-bubble.sn-user {
  align-self: flex-end;
  background: var(--sn-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sn-bubble a { color: var(--sn-accent); }
.sn-bubble.sn-user a { color: #fdba74; }

/* Typing indicator */
.sn-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px;
  background: var(--sn-bot); border-radius: 14px; border-bottom-left-radius: 4px; }
.sn-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--sn-muted);
  animation: sn-blink 1.2s infinite both; }
.sn-typing span:nth-child(2) { animation-delay: 0.2s; }
.sn-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sn-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Lead gate form */
.sn-gate {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sn-bg);
}
.sn-gate h3 { margin: 0; color: var(--sn-text); font-size: 1.05rem; }
.sn-gate p { margin: 0 0 4px; color: var(--sn-muted); font-size: 0.85rem; line-height: 1.5; }
.sn-field { display: flex; flex-direction: column; gap: 4px; }
.sn-field label { font-size: 0.78rem; font-weight: 600; color: var(--sn-text); }
.sn-field input {
  border: 1px solid var(--sn-border); border-radius: 10px; padding: 11px 12px;
  font-size: 0.9rem; font-family: inherit; color: var(--sn-text); background: #fff;
}
.sn-field input:focus { outline: none; border-color: var(--sn-accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.sn-gate-error { color: #dc2626; font-size: 0.8rem; min-height: 1em; }
.sn-btn {
  margin-top: 4px; border: none; cursor: pointer; border-radius: 10px;
  background: var(--sn-accent); color: #fff; font-weight: 700; font-size: 0.92rem;
  padding: 12px 14px; font-family: inherit; transition: background 160ms ease;
}
.sn-btn:hover { background: var(--sn-accent-hover); }
.sn-btn:disabled { opacity: 0.6; cursor: default; }
.sn-gate small { color: var(--sn-muted); font-size: 0.72rem; line-height: 1.4; }

/* Composer */
.sn-composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sn-border);
  background: var(--sn-bg);
}
.sn-composer textarea {
  flex: 1 1 auto; resize: none; border: 1px solid var(--sn-border); border-radius: 12px;
  padding: 10px 12px; font-size: 0.9rem; font-family: inherit; color: var(--sn-text);
  max-height: 110px; line-height: 1.4; background: #fff;
}
.sn-composer textarea:focus { outline: none; border-color: var(--sn-accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.sn-send {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--sn-accent); color: #fff; font-size: 16px; display: flex;
  align-items: center; justify-content: center; transition: background 160ms ease;
}
.sn-send:hover { background: var(--sn-accent-hover); }
.sn-send:disabled { opacity: 0.5; cursor: default; }

/* ---------- Mobile: near-fullscreen panel, never overlapping content ---------- */
@media (max-width: 768px) {
  .sn-panel {
    inset: 0;
    right: 0; bottom: 0;
    width: 100vw;
    height: 100dvh;            /* dynamic viewport — keyboard-safe */
    height: 100svh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
  }
}

/* Lock background scroll when the panel is open on mobile. */
html.sn-lock, html.sn-lock body { overflow: hidden; }
@media (min-width: 769px) {
  html.sn-lock, html.sn-lock body { overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .sn-launcher.sn-pulse { animation: none; }
  .sn-panel { transition: none; }
  .sn-typing span { animation: none; }
}
