/* Виджет поддержки: правый нижний угол */
#floory-support-root {
  --floory-spt-bg: rgba(18, 18, 22, 0.92);
  --floory-spt-border: rgba(110, 142, 247, 0.22);
  --floory-spt-accent: #6e8ef7;
  --floory-spt-text: #ececec;
  --floory-spt-muted: #8a8a94;
  --floory-spt-user-bubble: rgba(110, 142, 247, 0.18);
  --floory-spt-staff-bubble: rgba(52, 211, 153, 0.14);
  font-family: 'Manrope', system-ui, sans-serif;
  position: fixed;
  z-index: 999997;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  pointer-events: none;
}

#floory-support-root * {
  box-sizing: border-box;
}

html[data-theme="light"] #floory-support-root {
  --floory-spt-bg: rgba(252, 250, 255, 0.96);
  --floory-spt-border: rgba(110, 142, 247, 0.28);
  --floory-spt-text: #1a1a22;
  --floory-spt-muted: #5c5c68;
  --floory-spt-user-bubble: rgba(110, 142, 247, 0.2);
  --floory-spt-staff-bubble: rgba(52, 211, 153, 0.2);
}

html[data-theme="light"] #floory-support-root .floory-spt-msgs {
  scrollbar-color: rgba(90, 110, 200, 0.55) rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] #floory-support-root .floory-spt-msgs::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] #floory-support-root .floory-spt-msgs::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    rgba(90, 110, 200, 0.55),
    rgba(120, 85, 190, 0.45)
  );
  background-clip: padding-box;
}

#floory-support-root .floory-spt-fab {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--floory-spt-border);
  background: linear-gradient(145deg, var(--floory-spt-accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 8px 28px rgba(110, 142, 247, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#floory-support-root .floory-spt-fab:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 32px rgba(110, 142, 247, 0.45);
}

#floory-support-root .floory-spt-fab svg {
  width: 26px;
  height: 26px;
}

#floory-support-root .floory-spt-panel {
  pointer-events: auto;
  display: none;
  flex-direction: column;
  position: absolute;
  right: 0;
  bottom: calc(58px + 12px);
  width: min(100vw - 2rem, 360px);
  max-height: min(72vh, 520px);
  border-radius: 18px;
  border: 1px solid var(--floory-spt-border);
  background: var(--floory-spt-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#floory-support-root.floory-spt-open .floory-spt-panel {
  display: flex;
}

#floory-support-root.floory-spt-open .floory-spt-fab {
  opacity: 0.92;
}

/* Лёгкая анимация при авто-открытии после ответа поддержки */
#floory-support-root.floory-spt-highlight .floory-spt-panel {
  animation: floory-spt-glow 1.2s ease-out;
}
@keyframes floory-spt-glow {
  0% {
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.35),
      0 0 0 0 rgba(110, 142, 247, 0.45);
  }
  40% {
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.35),
      0 0 0 4px rgba(110, 142, 247, 0.2);
  }
  100% {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  }
}

#floory-support-root .floory-spt-head {
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--floory-spt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#floory-support-root .floory-spt-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--floory-spt-text);
  letter-spacing: -0.02em;
}

#floory-support-root .floory-spt-status {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--floory-spt-muted);
}

#floory-support-root .floory-spt-status.live {
  color: #34d399;
}

#floory-support-root .floory-spt-close {
  border: none;
  background: transparent;
  color: var(--floory-spt-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: 8px;
}

#floory-support-root .floory-spt-close:hover {
  color: var(--floory-spt-text);
  background: rgba(255, 255, 255, 0.06);
}

#floory-support-root .floory-spt-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 142, 247, 0.5) rgba(255, 255, 255, 0.06);
}

#floory-support-root .floory-spt-msgs::-webkit-scrollbar {
  width: 8px;
}

#floory-support-root .floory-spt-msgs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 100px;
  margin: 4px 0;
}

#floory-support-root .floory-spt-msgs::-webkit-scrollbar-thumb {
  border-radius: 100px;
  background: linear-gradient(
    180deg,
    rgba(110, 142, 247, 0.55),
    rgba(139, 92, 246, 0.45)
  );
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 40px;
}

#floory-support-root .floory-spt-msgs::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    rgba(110, 142, 247, 0.8),
    rgba(139, 92, 246, 0.65)
  );
  background-clip: padding-box;
}

#floory-support-root .floory-spt-msgs::-webkit-scrollbar-corner {
  background: transparent;
}

#floory-support-root .floory-spt-bubble {
  max-width: 88%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--floory-spt-text);
  word-break: break-word;
}

#floory-support-root .floory-spt-bubble.user {
  align-self: flex-end;
  background: var(--floory-spt-user-bubble);
  border: 1px solid rgba(110, 142, 247, 0.2);
}

#floory-support-root .floory-spt-bubble.staff {
  align-self: flex-start;
  background: var(--floory-spt-staff-bubble);
  border: 1px solid rgba(52, 211, 153, 0.22);
}

#floory-support-root .floory-spt-img-wrap {
  display: block;
  margin-bottom: 0.35rem;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  max-width: 100%;
}

#floory-support-root .floory-spt-img {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

#floory-support-root .floory-spt-text {
  word-break: break-word;
}

#floory-support-root .floory-spt-meta {
  font-size: 0.65rem;
  color: var(--floory-spt-muted);
  margin-top: 0.25rem;
  opacity: 0.85;
}

#floory-support-root .floory-spt-foot {
  padding: 0.65rem 0.75rem 0.85rem;
  border-top: 1px solid var(--floory-spt-border);
  display: flex;
  gap: 0.45rem;
}

#floory-support-root .floory-spt-input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--floory-spt-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--floory-spt-text);
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

#floory-support-root .floory-spt-input:focus {
  border-color: var(--floory-spt-accent);
}

#floory-support-root .floory-spt-send {
  border: none;
  border-radius: 12px;
  background: var(--floory-spt-accent);
  color: #fff;
  font-weight: 600;
  padding: 0 1rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: opacity 0.15s;
}

#floory-support-root .floory-spt-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#floory-support-root .floory-spt-hint {
  font-size: 0.78rem;
  color: var(--floory-spt-muted);
  padding: 1rem;
  text-align: center;
}
