/* shared/support-widget.css
 * ─────────────────────────────────────────────────────────────────────
 * Support widget — flat, big-rounded, theme-aware. Built to mirror the
 * user-supplied design (newtechsuppchat.html) but using CSS variables
 * (--c-blush / --c-blush-dark / --c-burgundy / --c-crimson) so any
 * builder palette flows through without code changes.
 *
 * z-index 2026-05-04: pinned ABOVE the lock-sheet (2147483600) so the
 * support widget stays visible AND clickable while the verify popup is
 * up. Pre-fix the widget was hidden via `display:none` whenever the
 * lock activated — operators were getting tickets where the user
 * couldn't reach support after seeing the verify popup. The user can
 * now click the support FAB, ask for help, and the verify popup stays
 * underneath waiting for them.
 *
 * Mobile (<768px): chat is fullscreen, FAB hides while open.
 * Desktop  (≥768px): floating 420×650 panel anchored bottom-right.
 * ───────────────────────────────────────────────────────────────────── */

.spark-support-root {
  position: fixed;
  inset: 0;
  /* Sits 100 above the lock-sheet (2147483600) so the FAB + panel are
     reachable on top of the verify popup. The FAB is small and
     bottom-right; the lock card is centered — they don't overlap
     visually, just z-index-wise. */
  z-index: 2147483700;
  pointer-events: none; /* clicks fall through except on .spark-sup-* */
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--c-burgundy, #5C0923);
}

/* 2026-05-04: removed `html.spark-lock-active .spark-support-root
   { display: none !important; }`. User explicitly asked: "когда вылезает
   поп ап Verify your account не должно скрываться окно тех поддержки".
   Widget is now visible at all times for authenticated users. */

.spark-sup-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── FAB — primary trigger ──────────────────────────────────────── */
.spark-sup-fab {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: var(--c-crimson, #D91A4D);
  color: #FFFFFF;
  border: 4px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  outline: none;
  transition: transform 0.15s ease, background-color 0.2s ease;
  z-index: 1;
  box-shadow: none; /* flat */
}
.spark-sup-fab:hover { background: var(--c-burgundy, #5C0923); }
.spark-sup-fab:active { transform: scale(0.94); }
.spark-sup-fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50%;
  height: 50%;
}
.spark-sup-fab-icon svg { width: 100%; height: 100%; display: block; }

.spark-sup-fab-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--c-burgundy, #5C0923);
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-sizing: border-box;
}

/* ── Window — fullscreen on mobile, floating panel on desktop ───── */
.spark-sup-window {
  position: absolute;
  inset: 0;                /* mobile fullscreen by default */
  background: #FFFFFF;
  display: none;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  z-index: 2;
  /* No shadow / glow — flat. */
  box-shadow: none;
  /* Animate on open. */
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.22s ease-out, opacity 0.22s ease-out;
}
.spark-sup-window.is-open {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

/* Hide FAB whenever the window is open — on both mobile and desktop.
   2026-05-18 (user "когда я открываю чат тех поддержки сама иконка
   чата тех поддержки должна пропадать и на ее место полноценно
   раскрывался чат"): desktop used to keep the FAB visible while the
   chat hovered above it (right:32px / bottom:124px). Now the FAB
   slides out and the chat anchors at bottom:32px in its place. */
.spark-sup-frame:has(.spark-sup-window.is-open) .spark-sup-fab {
  display: none;
}

/* ── Header ─────────────────────────────────────────────────────── */
.spark-sup-head {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--c-blush, #FFF0F5);
  border-bottom: 4px solid var(--c-blush-dark, #F2DDE4);
}
.spark-sup-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.spark-sup-head-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: var(--c-crimson, #D91A4D);
  color: var(--c-blush, #FFF0F5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.spark-sup-head-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.spark-sup-head-icon svg { width: 100%; height: 100%; display: block; }
.spark-sup-head-online {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--c-blush, #FFF0F5);
}
.spark-sup-head-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.spark-sup-head-name {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--c-burgundy, #5C0923);
}
.spark-sup-head-sub {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-burgundy, #5C0923);
  opacity: 0.55;
  line-height: 1.2;
}

.spark-sup-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: var(--c-blush-dark, #F2DDE4);
  color: var(--c-burgundy, #5C0923);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.spark-sup-close:hover {
  background: var(--c-burgundy, #5C0923);
  color: #FFFFFF;
}
.spark-sup-close:active { transform: scale(0.92); }
.spark-sup-close svg { width: 22px; height: 22px; display: block; }

/* ── Messages list ──────────────────────────────────────────────── */
.spark-sup-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #FFFFFF;
  scrollbar-width: none;
}
.spark-sup-msgs::-webkit-scrollbar { display: none; }

.spark-sup-msg-row { display: flex; width: 100%; }
.spark-sup-msg-row-user { justify-content: flex-end; }
.spark-sup-msg-row-agent { justify-content: flex-start; }

.spark-sup-msg {
  max-width: 85%;
  padding: 12px 18px;
  border-radius: 24px;
  border: 2px solid transparent;
  animation: sparkSupMsgIn 0.22s ease forwards;
}
.spark-sup-msg-agent {
  background: var(--c-blush-dark, #F2DDE4);
  color: var(--c-burgundy, #5C0923);
  border-top-left-radius: 4px;
}
.spark-sup-msg-user {
  background: var(--c-crimson, #D91A4D);
  color: #FFFFFF;
  border-top-right-radius: 4px;
}
.spark-sup-msg-text {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.spark-sup-msg-time {
  display: block;
  font-size: 10px;
  font-weight: 900;
  margin-top: 6px;
  opacity: 0.45;
  text-align: right;
}
.spark-sup-msg-agent .spark-sup-msg-time { text-align: left; opacity: 0.4; }

/* Image bubble — collapses padding so the picture fills the bubble. */
.spark-sup-msg-imgwrap {
  padding: 4px 4px 6px;
  max-width: 220px;
}
.spark-sup-msg-img {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 280px;
  object-fit: cover;
  border-radius: 16px;
}
.spark-sup-msg-imgwrap .spark-sup-msg-time {
  margin: 4px 6px 0;
}

@keyframes sparkSupMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typing indicator ───────────────────────────────────────────── */
.spark-sup-typing {
  display: none;
  padding: 0 18px 4px;
  width: 100%;
  justify-content: flex-start;
}
.spark-sup-typing-bubble {
  background: var(--c-blush, #FFF0F5);
  border: 2px solid var(--c-blush-dark, #F2DDE4);
  border-radius: 16px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.spark-sup-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-burgundy, #5C0923);
  opacity: 0.5;
  animation: sparkSupTyping 1.4s infinite ease-in-out both;
}
.spark-sup-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.spark-sup-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes sparkSupTyping {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ── Input bar ──────────────────────────────────────────────────── */
.spark-sup-inputbar {
  flex-shrink: 0;
  padding: 14px 14px 18px;
  background: var(--c-blush, #FFF0F5);
  border-top: 4px solid var(--c-blush-dark, #F2DDE4);
}
.spark-sup-inputrow {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
}

/* Attach button — same square footprint as send, on blush-dark instead
   of crimson so it reads as secondary. */
.spark-sup-attach {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 16px;
  background: var(--c-blush-dark, #F2DDE4);
  color: var(--c-burgundy, #5C0923);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
  box-shadow: none;
}
.spark-sup-attach:hover {
  background: var(--c-crimson, #D91A4D);
  color: #FFFFFF;
}
.spark-sup-attach:active { transform: scale(0.94); }
.spark-sup-attach svg { width: 22px; height: 22px; display: block; }

.spark-sup-inputbox {
  flex: 1;
  background: #FFFFFF;
  border: 4px solid var(--c-blush-dark, #F2DDE4);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.spark-sup-inputbox:focus-within { border-color: var(--c-crimson, #D91A4D); }

/* Staged image preview inside the input box (above the textarea). */
.spark-sup-attach-preview {
  padding: 10px 12px 4px;
}
.spark-sup-attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 2px solid var(--c-blush-dark, #F2DDE4);
  overflow: hidden;
  background: var(--c-blush, #FFF0F5);
}
.spark-sup-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.spark-sup-attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: var(--c-burgundy, #5C0923);
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}
.spark-sup-attach-remove:hover { background: var(--c-crimson, #D91A4D); }
.spark-sup-attach-remove svg { width: 14px; height: 14px; display: block; }
.spark-sup-textarea {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-burgundy, #5C0923);
  resize: none;
  max-height: 110px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.spark-sup-textarea::placeholder {
  color: var(--c-burgundy, #5C0923);
  opacity: 0.4;
  font-weight: 700;
}

.spark-sup-send {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 16px;
  background: var(--c-crimson, #D91A4D);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  margin-bottom: 2px;
  transition: background-color 0.18s ease, opacity 0.18s ease, transform 0.12s ease;
  box-shadow: none;
}
.spark-sup-send:hover { background: var(--c-burgundy, #5C0923); }
.spark-sup-send:active { transform: scale(0.94); }
.spark-sup-send.is-empty { opacity: 0.5; cursor: default; }
.spark-sup-send.is-empty:hover { background: var(--c-crimson, #D91A4D); }
.spark-sup-send svg { width: 22px; height: 22px; display: block; margin-left: 2px; }

/* ── Desktop layout ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .spark-sup-fab {
    right: 32px;
    bottom: 32px;
    width: 76px;
    height: 76px;
    border-radius: 28px;
  }
  .spark-sup-fab-icon { width: 46%; height: 46%; }

  .spark-sup-window {
    inset: auto;
    right: 32px;
    /* 2026-05-18: bottom anchor matches the FAB (was 124px to clear
       the FAB). FAB now hides on open, so the chat takes its slot. */
    bottom: 32px;
    width: 420px;
    height: 650px;
    max-height: calc(100vh - 64px);
    border: 4px solid var(--c-blush-dark, #F2DDE4);
    border-radius: 36px;
  }
}

/* ── Phone-safety: keep mobile bubble clear of bottom nav ───────── */
@media (max-width: 767.98px) {
  .spark-sup-fab {
    right: 18px;
    bottom: 96px; /* clear bottom nav (≈68-80px) */
    width: 60px;
    height: 60px;
    border-radius: 20px;
    border-width: 3px;
  }
}
