/* assistant.css - the site assistant widget: floating launcher button,
   chat panel, message bubbles, suggested questions, and the lead-capture
   form. Matches the redesign's visual language (css/premium.css tokens):
   ground/ink/teal/gold, Schibsted Grotesk display type, soft rounded
   cards. Loads after premium.css. */

.sa-launcher {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--teal, #0d9488);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 28px -12px rgba(13, 148, 136, 0.85);
  z-index: 900;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sa-launcher:hover { transform: translateY(-2px); }
.sa-launcher svg { width: 26px; height: 26px; }
.sa-launcher .sa-close-icon { display: none; }
.sa-launcher[aria-expanded="true"] .sa-chat-icon { display: none; }
.sa-launcher[aria-expanded="true"] .sa-close-icon { display: block; }

.sa-panel {
  position: fixed;
  right: 1.5rem;
  bottom: 5.5rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 620px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 60px -20px rgba(19, 28, 41, 0.4), 0 0 0 1px rgba(19, 28, 41, 0.06);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 899;
  font-family: 'Schibsted Grotesk', 'Helvetica Neue', Helvetica, sans-serif;
}
.sa-panel.is-open { display: flex; }
/* The panel is a <section>, so the site stylesheet's section padding
   (6rem, and 5rem on section:first-of-type, which outranks .sa-panel)
   lands on it and leaves blank bands above the header and below the
   disclaimer. Specific enough to beat both. */
section.sa-panel, section.sa-panel:first-of-type { padding: 0; }

.sa-header {
  background: var(--ink, #131c29);
  color: #fff;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}
.sa-header .sa-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal, #0d9488);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sa-header .sa-avatar svg { width: 18px; height: 18px; }
.sa-header-text { flex: 1; min-width: 0; }
.sa-header-title { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.sa-header-sub { font-size: 0.72rem; color: #b9c3d0; margin-top: 0.1rem; }
.sa-header-close {
  background: none; border: none; color: #b9c3d0; cursor: pointer;
  padding: 0.3rem; display: flex; border-radius: 8px;
}
.sa-header-close:hover { color: #fff; }

.sa-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--navy-deep, #f7f8fa);
}

.sa-msg {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.sa-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ink, #131c29);
  border-radius: 14px 14px 14px 4px;
  box-shadow: var(--shadow-card-sm, 0 4px 14px -8px rgba(19,28,41,0.2));
}
.sa-msg-user {
  align-self: flex-end;
  background: var(--teal, #0d9488);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}
.sa-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.sa-msg-assistant a { color: var(--teal-deep, #0b6f66); }

.sa-typing { display: inline-flex; gap: 4px; padding: 0.5rem 0.2rem; }
.sa-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-3, #8a95a3); animation: sa-bounce 1s ease-in-out infinite; }
.sa-typing span:nth-child(2) { animation-delay: 0.15s; }
.sa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sa-bounce { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sa-typing span { animation: none; opacity: 1; } }

.sa-suggestions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; }
.sa-suggestion-btn {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line, #e8ebef);
  color: var(--teal-deep, #0b6f66);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.sa-suggestion-btn:hover { border-color: var(--teal, #0d9488); background: var(--teal-tint, #e6f4f2); }

.sa-getintouch {
  align-self: center;
  margin-top: 0.25rem;
  background: none;
  border: 1px dashed var(--line, #e8ebef);
  color: var(--muted-2, #6b7889);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}
.sa-getintouch:hover { border-color: var(--teal, #0d9488); color: var(--teal-deep, #0b6f66); }

.sa-footer { border-top: 1px solid var(--line, #e8ebef); padding: 0.75rem; flex-shrink: 0; background: #fff; }
.sa-input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.sa-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line, #e8ebef);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: inherit;
  max-height: 90px;
  color: var(--ink, #131c29);
}
.sa-input:focus { outline: 2px solid var(--teal, #0d9488); outline-offset: 1px; }
.sa-send {
  background: var(--teal, #0d9488);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sa-send:disabled { opacity: 0.5; cursor: default; }
.sa-charcount { font-size: 0.68rem; color: var(--muted-3, #8a95a3); text-align: right; margin-top: 0.25rem; }
.sa-disclaimer {
  margin: 0;
  padding: 0 0.9rem 0.6rem;
  padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  flex-shrink: 0;
  background: #fff;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--muted-2, #6b7889);
  text-align: center;
}
.sa-disclaimer a { color: var(--teal-deep, #0b6f66); text-decoration: underline; white-space: nowrap; }
.sa-notice { font-size: 0.76rem; color: var(--muted-2, #6b7889); padding: 0.5rem 1rem; text-align: center; }
.sa-error { font-size: 0.8rem; color: #b3261e; padding: 0.5rem 1rem; text-align: center; }

/* ── Lead form ── */
.sa-lead-form { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.25rem; }
.sa-lead-form h3 { font-size: 0.95rem; margin: 0 0 0.2rem; color: var(--ink, #131c29); }
.sa-lead-form label { font-size: 0.78rem; font-weight: 600; color: var(--ink-2, #3b475a); display: flex; flex-direction: column; gap: 0.25rem; }
.sa-lead-form input[type="text"],
.sa-lead-form input[type="email"],
.sa-lead-form input[type="tel"] {
  border: 1px solid var(--line, #e8ebef);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  font-family: inherit;
}
.sa-lead-form input:focus { outline: 2px solid var(--teal, #0d9488); outline-offset: 1px; }
.sa-consent { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.74rem; color: var(--muted-2, #6b7889); font-weight: 400; }
.sa-consent input { margin-top: 0.15rem; }
.sa-consent a { color: var(--teal-deep, #0b6f66); }
.sa-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sa-lead-submit {
  background: var(--teal, #0d9488); color: #fff; border: none; border-radius: 10px;
  padding: 0.6rem; font-weight: 700; font-size: 0.86rem; cursor: pointer; margin-top: 0.25rem;
}
.sa-lead-submit:disabled { opacity: 0.6; cursor: default; }
.sa-lead-cancel { background: none; border: none; color: var(--muted-2, #6b7889); font-size: 0.78rem; text-decoration: underline; cursor: pointer; align-self: center; }

/* ── Mobile: full-height sheet ── */
@media (max-width: 640px) {
  .sa-panel {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100%; height: 100%; max-height: none; max-width: none;
    border-radius: 0;
  }
  .sa-launcher { right: 1rem; bottom: 1rem; }
  /* Full-screen panel: the launcher would sit over the footer and the
     disclaimer, and the header already has a close button. closePanel()
     resets aria-expanded before it focuses the launcher, so focus lands
     on a visible element. */
  .sa-launcher[aria-expanded="true"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sa-launcher, .sa-panel { transition: none; }
}
