/* Support assistant (/support/). Tokens come from /assets/site.css; this file
   only lays out the chat. Mobile first: most people arrive from the app. */

html, body.sp-body { height: 100%; }
.sp-body [hidden] { display: none !important; }
body.sp-body {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  background: var(--background); color: var(--foreground);
  overflow: hidden;
}

/* ── Header ── */
.sp-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.sp-head .logo { font-size: 20px; display: inline-flex; align-items: center; min-height: 44px; }
.sp-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.sp-title strong { font-size: var(--fs-sm); font-weight: 800; }
.sp-title span {
  font-size: var(--fs-xs); color: var(--muted-foreground);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right;
}
.sp-headbtn {
  position: relative;
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px;
  font: inherit; font-size: var(--fs-xs); font-weight: 700; color: var(--foreground);
  background: transparent; border: 1px solid var(--input); border-radius: var(--shape-pill);
  cursor: pointer; white-space: nowrap;
}
.sp-headbtn:hover { background: var(--secondary); }
.sp-dot {
  position: absolute; top: -3px; left: -3px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); border: 2px solid var(--card);
}

/* ── Conversation ── */
.sp-chat {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 760px; margin: 0 auto;
}
.sp-msg { display: flex; animation: sp-in 200ms var(--motion-ease) both; }
.sp-msg.user { justify-content: flex-end; }
.sp-msg.bot { justify-content: flex-start; }
.sp-bubble {
  max-width: min(88%, 560px);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.9;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.sp-msg.bot .sp-bubble { background: var(--card); border: 1px solid var(--border); border-start-start-radius: 6px; }
.sp-msg.user .sp-bubble { background: var(--brand); color: var(--brand-foreground); border-end-end-radius: 6px; }
.sp-bubble a { color: var(--brand-text); text-decoration: underline; text-underline-offset: 3px; }
.sp-bubble a.sp-btn { color: var(--foreground); }
.sp-bubble h3 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.sp-bubble .sp-sub { font-size: var(--fs-xs); color: var(--muted-foreground); }
.sp-day { align-self: center; font-size: var(--fs-xs); color: var(--muted-foreground); padding: 4px 0; }

@keyframes sp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sp-msg { animation: none; } }

/* Typing indicator */
.sp-typing { display: inline-flex; gap: 4px; align-items: center; height: 26px; }
.sp-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted-foreground);
  animation: sp-blink 1.2s infinite ease-in-out both;
}
.sp-typing i:nth-child(2) { animation-delay: 0.15s; }
.sp-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes sp-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Buttons inside a bubble */
.sp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; white-space: normal; }
.sp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  font: inherit; font-size: var(--fs-sm); font-weight: 700; line-height: 1.4; text-align: center;
  color: var(--foreground); background: var(--secondary);
  border: 1px solid var(--input); border-radius: 12px; cursor: pointer;
  text-decoration: none !important;
  transition: background var(--motion) var(--motion-ease), transform var(--motion) var(--motion-ease);
}
.sp-btn:hover { background: var(--surface-3, #1d1d1f); }
.sp-btn:active { transform: var(--press); }
.sp-btn.primary { background: var(--brand); border-color: transparent; color: var(--brand-foreground) !important; }
.sp-btn.primary:hover { background: #ff4750; }
.sp-btn.quiet { background: transparent; color: var(--muted-foreground); }
.sp-btn[disabled] { opacity: 0.5; cursor: default; pointer-events: none; }
.sp-actions.done .sp-btn:not(.keep) { opacity: 0.45; pointer-events: none; }

/* Forms inside a bubble */
.sp-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; white-space: normal; }
.sp-form label { font-size: var(--fs-xs); color: var(--muted-foreground); }
.sp-form input, .sp-form textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: 16px; /* 16px: iOS zooms the page on anything smaller */
  color: var(--foreground); background: var(--background);
  border: 1px solid var(--input); border-radius: 10px;
}
.sp-form textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.sp-form input:focus, .sp-form textarea:focus { outline: none; border-color: var(--ring); }
.sp-form input[dir="ltr"] { text-align: left; }
.sp-form .sp-btn { align-self: flex-start; }
.sp-note { font-size: var(--fs-xs); color: var(--muted-foreground); line-height: 1.7; }

/* Status lines and lists */
.sp-find { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; white-space: normal; }
.sp-find::before { content: ''; flex: 0 0 8px; height: 8px; margin-top: 11px; border-radius: 50%; background: var(--muted-foreground); }
.sp-find.good::before { background: var(--success); }
.sp-find.warn::before { background: var(--warning); }
.sp-find.bad::before { background: var(--destructive); }
.sp-rows { margin-top: 8px; border-top: 1px solid var(--border); white-space: normal; }
.sp-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm);
}
.sp-row small { display: block; color: var(--muted-foreground); font-size: var(--fs-xs); }
.sp-pill {
  flex: 0 0 auto; padding: 2px 8px; border-radius: var(--shape-pill);
  font-size: 11px; font-weight: 700; background: var(--secondary); color: var(--muted-foreground);
}
.sp-pill.good { background: rgba(42, 204, 138, 0.14); color: var(--success); }
.sp-pill.warn { background: rgba(250, 183, 42, 0.14); color: var(--warning); }
.sp-pill.bad { background: rgba(241, 77, 76, 0.14); color: var(--destructive); }
.sp-ok { color: var(--success); font-weight: 700; }
.sp-err { color: #ff8a85; }

/* Ticket thread */
.sp-thread-admin .sp-bubble { border-color: var(--brand-line); }
.sp-from { display: block; font-size: 11px; font-weight: 700; color: var(--brand-text); margin-bottom: 2px; }

/* ── Footer: topic chips + composer ── */
.sp-foot {
  flex: 0 0 auto;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
}
.sp-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.sp-chips::-webkit-scrollbar { display: none; }
.sp-chip {
  flex: 0 0 auto; min-height: 36px; padding: 0 14px;
  font: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--foreground);
  background: var(--card); border: 1px solid var(--input); border-radius: var(--shape-pill);
  cursor: pointer; white-space: nowrap;
}
.sp-chip:hover { background: var(--secondary); }
.sp-composer {
  display: flex; align-items: center; gap: 8px;
  padding: 6px; padding-inline-start: 14px;
  background: var(--card); border: 1px solid var(--input); border-radius: 26px;
}
.sp-composer:focus-within { border-color: var(--ring); }
.sp-composer input {
  flex: 1; min-width: 0; min-height: 40px;
  font: inherit; font-size: 16px; color: var(--foreground);
  background: transparent; border: 0; outline: none;
}
.sp-composer input::placeholder { color: var(--muted-foreground); }
.sp-send {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-foreground); background: var(--brand); border: 0; cursor: pointer;
}
.sp-send svg { width: 20px; height: 20px; }
.sp-send:active { transform: var(--press); }

@media (min-width: 720px) {
  .sp-chat { padding-top: 24px; }
  .sp-chips { flex-wrap: wrap; overflow: visible; }
  .sp-bubble { font-size: 16px; }
}
