/* Виджет поддержки: чат справа снизу */
.support-chat {
  --sc-bg: rgba(12, 13, 18, 0.98);
  --sc-border: rgba(255, 255, 255, 0.12);
  --sc-muted: rgba(255, 255, 255, 0.62);
  --sc-text: rgba(255, 255, 255, 0.92);
  --sc-user-bg: linear-gradient(135deg, #ff2b2b, #ff5a2b);
  --sc-bot-bg: rgba(255, 255, 255, 0.08);
  --sc-accent: #ff3a3a;
  position: fixed;
  z-index: 10050;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  pointer-events: none;
}

.support-chat > * {
  pointer-events: auto;
}

.support-chat--pending {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  visibility: hidden;
}

.support-chat--pending > * {
  pointer-events: none;
}

.support-chat--visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: opacity 320ms ease, transform 320ms ease, visibility 0s linear 0s;
}

.support-chat__toggle {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, #ff2b2b, #ff5a2b);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 16px 44px rgba(255, 43, 43, 0.32);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.support-chat__toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 52px rgba(255, 43, 43, 0.4);
  filter: brightness(1.04);
}

.support-chat__toggle:active {
  transform: translateY(0);
}

.support-chat__toggle .support-chat__icon-close {
  display: none;
  font-size: 24px;
}

.support-chat.is-open .support-chat__toggle .support-chat__icon-open {
  display: none;
}

.support-chat.is-open .support-chat__toggle .support-chat__icon-close {
  display: inline;
}

.support-chat__panel {
  width: min(380px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--sc-border);
  background: var(--sc-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  transform-origin: bottom right;
  transform: translateY(8px) scale(0.97);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms;
}

.support-chat.is-open .support-chat__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.support-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--sc-border);
  background: rgba(255, 255, 255, 0.03);
}

.support-chat__title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.support-chat__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--sc-muted);
  font-weight: 500;
}

.support-chat__close {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 160ms ease, border-color 160ms ease;
}

.support-chat__close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.support-chat__messages {
  flex: 1;
  min-height: 220px;
  max-height: min(380px, 52vh);
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.support-chat__msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.support-chat__msg--bot {
  align-self: flex-start;
  background: var(--sc-bot-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sc-text);
  border-bottom-left-radius: 6px;
}

.support-chat__msg--user {
  align-self: flex-end;
  background: var(--sc-user-bg);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 24px rgba(255, 43, 43, 0.18);
}

.support-chat__msg--error {
  align-self: stretch;
  max-width: none;
  background: rgba(255, 60, 60, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.35);
  color: rgba(255, 200, 200, 0.95);
  font-size: 12px;
}

.support-chat__typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
  font-size: 12px;
  color: var(--sc-muted);
  font-weight: 500;
}

.support-chat__typing.is-visible {
  display: flex;
}

.support-chat__typing-dots {
  display: inline-flex;
  gap: 3px;
}

.support-chat__typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sc-accent);
  opacity: 0.35;
  animation: support-chat-dot 1.2s ease-in-out infinite;
}

.support-chat__typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.support-chat__typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes support-chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.support-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 4px;
  align-self: stretch;
  max-width: 100%;
}

.support-chat__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  cursor: pointer;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.support-chat__chip:hover {
  background: rgba(255, 60, 60, 0.18);
  border-color: rgba(255, 90, 60, 0.45);
  transform: translateY(-1px);
}

.support-chat__chip:active {
  transform: translateY(0);
}

.support-chat__hint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .support-chat--visible,
  .support-chat__panel,
  .support-chat__toggle,
  .support-chat__typing-dots span {
    animation: none;
    transition: none;
  }
}
