/* skbpa:product.assistant — «Онлайн-помощь».

   A compact support window, not a full-screen modal. On desktop it docks to the
   bottom-right in the shape people already read as "live help", leaving the
   product page visible behind it; on phones it takes the viewport because
   anything smaller is unusable with a keyboard open.

   Visual register is deliberately industrial-professional: one restrained
   accent, no gradients, no avatars, no "AI" glow. It should look like SKB
   technical support, not a consumer messenger. */

.skbpa-as {
  --as-accent: #e36d38;
  --as-accent-deep: #b14819;
  --as-ink: #211d19;
  --as-ink-soft: #5c564d;
  --as-ink-faint: #918a7d;
  --as-line: #e7e2da;
  --as-surface: #fff;
  --as-surface-2: #f7f5f2;
  --as-bot: #f4f2ef;

  position: fixed;
  inset: auto 24px 24px auto;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  margin: 0;
  padding: 0;
  border: 1px solid var(--as-line);
  border-radius: 12px;
  background: var(--as-surface);
  color: var(--as-ink);
  box-shadow: 0 18px 48px rgba(24, 20, 16, .20);
  overflow: hidden;

  /* NO display here. A bare `display: flex` on the element overrides the UA
     rule `dialog:not([open]) { display: none }`, so the panel rendered inline
     in the page even while closed — and at mobile widths, where it is
     inset:0, that invisible-but-present box covered the viewport and
     swallowed the very click meant to open it. Only [open] gets a display. */
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
}

.skbpa-as[open] { display: flex; }

/* Barely-there backdrop: the point of a docked support window is that the page
   behind it stays readable — you are usually looking something up ON it. At .18
   the page was noticeably greyed out, which made the panel read as a blocking
   modal instead of a companion. */
.skbpa-as::backdrop { background: rgba(24, 20, 16, .06); }

/* --- head -------------------------------------------------------------- */

.skbpa-as__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--as-line);
  background: var(--as-surface-2);
}

.skbpa-as__head-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1 1 auto;
}

.skbpa-as__mark {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #fdf1ea;
  color: var(--as-accent-deep);
}

.skbpa-as__mark svg { width: 19px; height: 19px; }

.skbpa-as__head-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.skbpa-as__title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
}

/* The product name is the whole point of a contextual assistant — it says
   "I already know what you are looking at". */
.skbpa-as__subject {
  font-size: 12px;
  color: var(--as-ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skbpa-as__close {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--as-ink-faint);
  cursor: pointer;
}

.skbpa-as__close svg { width: 17px; height: 17px; }

.skbpa-as__close:hover,
.skbpa-as__close:focus-visible {
  background: rgba(0, 0, 0, .06);
  color: var(--as-ink);
}

/* --- body -------------------------------------------------------------- */

.skbpa-as__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skbpa-as__body:focus { outline: none; }
.skbpa-as__body:focus-visible { outline: 2px solid var(--as-accent); outline-offset: -2px; }

.skbpa-as__msg {
  max-width: 92%;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13.5px;
}

.skbpa-as__msg p { margin: 0 0 7px; }
.skbpa-as__msg p:last-child { margin-bottom: 0; }

.skbpa-as__msg--bot {
  align-self: flex-start;
  background: var(--as-bot);
  border-bottom-left-radius: 3px;
}

.skbpa-as__msg--user {
  align-self: flex-end;
  background: #fdf1ea;
  border: 1px solid #f3ddd0;
  border-bottom-right-radius: 3px;
}

.skbpa-as__msg-note { color: var(--as-ink-soft); font-size: 12.5px; }

/* Labels a reply that is NOT a settled answer. Non-negotiable: a knowledge gap
   or a source conflict must be visibly a different kind of thing from an
   answer, or the visitor reads the surrounding prose as one anyway. A plain
   answer carries no badge — the sources under it are its credential. */
.skbpa-as__badge {
  display: inline-block;
  margin: 0 0 7px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f6;
  color: #46536b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.skbpa-as__badge--gap { background: #f3efe6; color: #7a6432; }
.skbpa-as__badge--conflict { background: #fbeceb; color: #9a3b32; }
.skbpa-as__badge--clarify { background: #eaf1f5; color: #38596b; }

/* The clarifying question itself, set apart from the sentence that leads to
   it — it is the thing the visitor is being asked to act on. */
.skbpa-as__ask {
  margin-top: 8px;
  font-weight: 600;
}

/* --- sources ------------------------------------------------------------ */

.skbpa-as__sources {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--as-line);
}

.skbpa-as__sources-head {
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--as-ink-faint);
}

/* ONE source, ONE card.
   The kind and the title used to sit side by side inside the chip — a small
   uppercase pill, then the document name — and read as two separate links to
   the same page. Stacked, they read as what they are: which kind of document,
   then which document. Both halves stay inside the single <a>, so the whole
   card is one click and the deep link is unchanged. */
.skbpa-as__sources .skbpa-as__chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Scoped under .skbpa-as__sources on purpose: the base .skbpa-as__chip rule is
   declared LATER in this file, so at equal specificity it wins and the card
   went back to align-items:center — the label sat centred over a left-aligned
   title. Measured, not eyeballed. The action chips outside this block keep the
   base styling. */
.skbpa-as__sources .skbpa-as__chip--source {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  max-width: 100%;
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
}

.skbpa-as__sources .skbpa-as__chip-kind {
  /* Not uppercase any more: it now reads «Руководство по эксплуатации», and
     a whole line of capitals is a shout, not a label. */
  color: var(--as-ink-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
}

.skbpa-as__sources .skbpa-as__chip-title {
  width: 100%;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.35;
}

.skbpa-as__sources .skbpa-as__chip--source:hover .skbpa-as__chip-kind,
.skbpa-as__sources .skbpa-as__chip--source:focus-visible .skbpa-as__chip-kind {
  color: var(--as-accent-deep);
}

/* A product named in the answer is a link to its catalogue page. Underlined
   rather than coloured-only: inside a paragraph of technical prose, colour
   alone is easy to miss and impossible for some readers to see at all. */
.skbpa-as__product-link {
  color: var(--as-accent-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.skbpa-as__product-link:hover,
.skbpa-as__product-link:focus-visible {
  text-decoration-thickness: 2px;
}

/* --- pending ------------------------------------------------------------ */

/* Retrieval plus a verified answer takes a few seconds, and correctness is
   worth more than streaming here (§31) — so the wait needs to look deliberate
   rather than broken. */
.skbpa-as__typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 13px;
}

.skbpa-as__typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--as-ink-faint);
  animation: skbpa-as-pulse 1.1s ease-in-out infinite;
}

.skbpa-as__typing i:nth-child(2) { animation-delay: .18s; }
.skbpa-as__typing i:nth-child(3) { animation-delay: .36s; }

@keyframes skbpa-as-pulse {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: .85; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .skbpa-as__typing i { animation: none; opacity: .5; }
}

.skbpa-as__input:disabled,
.skbpa-as__send:disabled {
  opacity: .55;
  cursor: default;
}

.skbpa-as__send:disabled:hover { background: var(--as-accent); }

/* --- quick actions ------------------------------------------------------ */

.skbpa-as__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skbpa-as__chips--inline { margin-top: 9px; }

.skbpa-as__chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--as-line);
  border-radius: 999px;
  background: var(--as-surface);
  color: var(--as-ink);
  font-size: 13px;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}

.skbpa-as__chip:hover,
.skbpa-as__chip:focus-visible {
  border-color: var(--as-accent);
  background: #fdf6f2;
  color: var(--as-accent-deep);
  text-decoration: none;
}

.skbpa-as__chip:focus-visible {
  outline: 2px solid var(--as-accent);
  outline-offset: 2px;
}

/* --- input -------------------------------------------------------------- */

.skbpa-as__form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-top: 1px solid var(--as-line);
  background: var(--as-surface);
}

.skbpa-as__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--as-line);
  border-radius: 999px;
  background: var(--as-surface-2);
  color: var(--as-ink);
  font-size: 13.5px;
}

.skbpa-as__input:focus {
  outline: none;
  border-color: var(--as-accent);
  background: var(--as-surface);
}

.skbpa-as__send {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--as-accent);
  color: #fff;
  cursor: pointer;
}

.skbpa-as__send svg { width: 17px; height: 17px; }
.skbpa-as__send:hover { background: var(--as-accent-deep); }
.skbpa-as__send:focus-visible { outline: 2px solid var(--as-accent-deep); outline-offset: 2px; }

.skbpa-as__disclaimer {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 11px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--as-ink-faint);
  background: var(--as-surface);
}

.skbpa-as__sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- mobile ------------------------------------------------------------- */

@media (max-width: 600px) {
  .skbpa-as {
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
    /* dvh keeps the input reachable when the on-screen keyboard appears; the
       vh fallback above matters for browsers without it. */
    height: 100dvh;
    max-height: 100dvh;
  }
  .skbpa-as__msg { max-width: 100%; }
}

/* Cloudflare challenge, shown inline in the conversation only when the server
   asks for one. Centred so it does not read as part of an answer. */
.skbpa-as__turnstile {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}
