/* Slipity Pro docs chat — the floating "Ask" button and its panel.
   Restyle it with the custom properties below; light first, then dark. Everything else in this
   file reads them, and nothing here touches the host page outside .sp-chat. */

.sp-chat {
  --chat-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --chat-font-size: 15px;
  --chat-radius: 18px;          /* the panel's corners */
  --chat-bubble-radius: 14px;   /* messages and their pictures */
  --chat-pill-radius: 22px;     /* starter links and the input: half a line's height, so pills */
  --chat-width: 380px;          /* the panel, on screens wider than a phone */
  --chat-height: 600px;
  --chat-offset: 20px;          /* from the bottom and right edges */
  --chat-z: 2147483000;

  --chat-accent: #eb8d00;       /* the launcher, send button and focus rings */
  --chat-on-accent: #ffffff;
  --chat-bg: #ffffff;
  --chat-surface: #f5f5f7;      /* answers, starter links, the input */
  --chat-border: rgba(0, 0, 0, 0.1);
  --chat-text: #1d1d1f;
  --chat-muted: #6e6e73;
  --chat-link: #0066cc;
  --chat-user-bg: #eb8d00;      /* the visitor's own messages */
  --chat-user-text: #ffffff;
  --chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .sp-chat {
    --chat-bg: #1d1d1f;
    --chat-surface: #2c2c2e;
    --chat-border: rgba(255, 255, 255, 0.12);
    --chat-text: #f5f5f7;
    --chat-muted: #a1a1a6;
    --chat-link: #2997ff;
    --chat-user-bg: #c97400;
    --chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  }
}

/* Layout */

.sp-chat, .sp-chat * { box-sizing: border-box; }

.sp-chat {
  font-family: var(--chat-font);
  font-size: var(--chat-font-size);
  line-height: 1.45;
  letter-spacing: normal;
  color: var(--chat-text);
}

.sp-chat-launcher {
  position: fixed;
  right: calc(var(--chat-offset) + env(safe-area-inset-right));
  bottom: calc(var(--chat-offset) + env(safe-area-inset-bottom));
  z-index: var(--chat-z);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
  font: 600 var(--chat-font-size) / 1 var(--chat-font);
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.sp-chat-launcher:hover { transform: translateY(-1px); }
.sp-chat-launcher svg { width: 26px; height: 26px; flex: none; }
.sp-chat[data-open] .sp-chat-launcher { display: none; }

.sp-chat-panel {
  position: fixed;
  right: calc(var(--chat-offset) + env(safe-area-inset-right));
  bottom: calc(var(--chat-offset) + env(safe-area-inset-bottom));
  z-index: var(--chat-z);
  display: flex;
  flex-direction: column;
  width: var(--chat-width);
  margin: 0;
  padding: 0;
  height: min(var(--chat-height), calc(100dvh - 2 * var(--chat-offset)));
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  box-shadow: var(--chat-shadow);
  overflow: hidden;
}
.sp-chat-panel[hidden] { display: none; }

/* A phone: the panel fills the screen, as a sheet. */
@media (max-width: 520px) {
  .sp-chat-panel {
    inset: 0;
    width: auto;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

.sp-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 18px;
  border-bottom: 1px solid var(--chat-border);
}
.sp-chat-title { margin: 0; flex: 1; font-size: 1.05em; font-weight: 600; }
.sp-chat-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-surface);
  color: var(--chat-muted);
  cursor: pointer;
}
.sp-chat-close svg { width: 14px; height: 14px; }

.sp-chat-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 8px;
}

/* Before the first question */

.sp-chat-intro { margin: 0 0 12px; color: var(--chat-muted); }
.sp-chat-starters { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.sp-chat-starters a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--chat-pill-radius);
  background: var(--chat-surface);
  color: var(--chat-text);
  text-decoration: none;
}
.sp-chat-starters a:hover { color: var(--chat-link); }
.sp-chat-starters a::after { content: "↗"; color: var(--chat-muted); }

/* Messages */

.sp-chat-messages { display: grid; gap: 12px; }
.sp-chat-message { max-width: 88%; padding: 10px 14px; border-radius: var(--chat-bubble-radius); overflow-wrap: anywhere; }
.sp-chat-message[data-role="user"] { justify-self: end; background: var(--chat-user-bg); color: var(--chat-user-text); white-space: pre-wrap; }
.sp-chat-message[data-role="assistant"] { justify-self: start; background: var(--chat-surface); }
.sp-chat-message p, .sp-chat-message ul, .sp-chat-message ol { margin: 0 0 0.6em; }
.sp-chat-message > :last-child { margin-bottom: 0; }
.sp-chat-message ul, .sp-chat-message ol { padding-left: 1.3em; }
.sp-chat-message ul { list-style: disc; }
.sp-chat-message ol { list-style: decimal; }
.sp-chat-message code { font-size: 0.9em; }
.sp-chat-message[data-pending]::after { content: "…"; color: var(--chat-muted); }
.sp-chat-message[data-error] { color: var(--chat-muted); }

/* Screenshots and videos from the docs, under an answer */

.sp-chat-media { display: grid; gap: 10px; margin-top: 10px; }
.sp-chat-media figure { margin: 0; }
.sp-chat-media img, .sp-chat-media video, .sp-chat-media iframe {
  display: block;
  width: 100%;
  border: 0;
  border-radius: calc(var(--chat-bubble-radius) - 6px);
  background: var(--chat-bg);
}
.sp-chat-media iframe { aspect-ratio: 16 / 9; height: auto; }
.sp-chat-media figcaption { margin-top: 4px; font-size: 0.85em; color: var(--chat-muted); }

.sp-chat-sources { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--chat-border); font-size: 0.88em; }
.sp-chat-sources p { margin: 0 0 4px; color: var(--chat-muted); }
.sp-chat-sources ul { list-style: none; margin: 0; padding: 0; }
.sp-chat-sources a { color: var(--chat-link); }

/* The question box and the way to a person */

.sp-chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 4px; }
.sp-chat-input {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 10px 16px;
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-pill-radius);
  background: var(--chat-surface);
  color: var(--chat-text);
  font: inherit;
  font-size: max(16px, var(--chat-font-size)); /* below 16px, iPhone zooms the page in on focus */
  resize: none;
}
.sp-chat-send {
  flex: none;
  width: 44px;
  height: 44px;               /* a circle, kept at the bottom as the question grows */
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
  cursor: pointer;
}
.sp-chat-send svg { width: 18px; height: 18px; margin: auto; display: block; }
.sp-chat-send:disabled { opacity: 0.5; cursor: default; }

.sp-chat-footer { margin: 0; padding: 6px 16px 12px; font-size: 0.85em; color: var(--chat-muted); text-align: center; }
.sp-chat-footer a { color: var(--chat-link); font-weight: 600; }

.sp-chat :focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 2px; }
.sp-chat-input:focus-visible { outline-offset: 0; }

.sp-chat-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .sp-chat-launcher { transition: none; }
}
