/* Помощник БизонАрены.
   Телефон: отдельный неподвижный экран переписки поверх сайта.
   Компьютер: окно в правом нижнем углу. */

.bchat {
  font-family: var(--font-body);
}

/* Кнопка вызова */
.bchat__fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px 0 16px;
  background: #04120a;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 999px;
  font: 700 15px/1 var(--font-body);
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 18px var(--green-glow);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s, background 0.45s, box-shadow 0.45s;
}

.bchat__fab--away {
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.bchat__fab:hover {
  transform: translateY(-2px);
  background: #062012;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 26px var(--green-glow);
}

.bchat__fab svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.bchat.is-open .bchat__fab {
  display: none;
}

/* Окно */
.bchat__panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  width: 392px;
  height: min(640px, calc(100vh - 40px));
  height: min(640px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.bchat__panel[hidden] {
  display: none;
}

@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
  .bchat.is-open .bchat__panel {
    animation: bchat-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes bchat-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* Шапка */
.bchat__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 12px 16px;
  background: #04120a;
  border-bottom: 1px solid var(--border);
}

.bchat__mark {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: rgba(0, 230, 90, 0.08);
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}

.bchat__who {
  flex: 1;
  min-width: 0;
}

.bchat__title {
  margin: 0;
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bchat__status {
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.bchat__status::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.bchat__back,
.bchat__close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.4s, color 0.4s;
}

.bchat__back {
  display: none;
}

.bchat__back:hover,
.bchat__close:hover {
  border-color: var(--border);
  color: var(--green);
}

.bchat__back svg,
.bchat__close svg {
  width: 22px;
  height: 22px;
}

/* Переписка */
.bchat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bchat__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bchat__msg--bot {
  align-self: flex-start;
  background: #0a1f12;
  border: 1px solid rgba(0, 230, 90, 0.16);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.bchat__msg--user {
  align-self: flex-end;
  background: var(--green);
  border-bottom-right-radius: 4px;
  color: #00150a;
  font-weight: 600;
}

.bchat__msg--ok {
  border-color: var(--green);
}

.bchat__msg a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bchat__note {
  align-self: center;
  max-width: 92%;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.bchat__typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 15px 16px;
}

.bchat__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bchat-dot 1.2s infinite;
}

.bchat__typing i:nth-child(2) {
  animation-delay: 0.2s;
}

.bchat__typing i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bchat-dot {
  0%,
  60%,
  100% {
    opacity: 0.25;
  }
  30% {
    opacity: 1;
  }
}

/* Быстрые вопросы */
.bchat__quick {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.bchat__quick::-webkit-scrollbar {
  display: none;
}

.bchat__quick[hidden] {
  display: none;
}

.bchat__chip {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--green);
  font: 600 14px/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.4s, border-color 0.4s;
}

.bchat__chip:hover {
  background: rgba(0, 230, 90, 0.1);
  border-color: var(--green);
}

/* Поле ввода */
.bchat__form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #04120a;
  border-top: 1px solid var(--border);
}

.bchat__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font: 16px/1.4 var(--font-body);
  resize: none;
  outline: none;
}

.bchat__input::placeholder {
  color: var(--muted);
}

.bchat__input:focus {
  border-color: var(--green);
}

.bchat__send {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--green);
  border: none;
  border-radius: 50%;
  color: #00150a;
  cursor: pointer;
}

.bchat__send svg {
  width: 20px;
  height: 20px;
}

.bchat__send:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Телефон: экран переписки на всю видимую область, без анимаций */
@media (max-width: 768px) {
  /* Круглая кнопка без подписи: не закрывает кнопки страницы на первом экране */
  .bchat__fab {
    right: max(14px, env(safe-area-inset-right, 0px));
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    min-height: 0;
    padding: 0;
    justify-content: center;
  }

  .bchat__fab span {
    display: none;
  }

  .bchat__fab svg {
    width: 24px;
    height: 24px;
  }

  .bchat__panel {
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .bchat__head {
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px
      max(4px, env(safe-area-inset-left, 0px));
  }

  .bchat__back {
    display: grid;
  }

  .bchat__close {
    display: none;
  }

  .bchat__mark {
    width: 36px;
    height: 36px;
  }

  .bchat__log {
    padding: 14px 12px;
  }

  .bchat__msg {
    max-width: 86%;
  }

  .bchat__quick {
    padding: 0 12px 10px;
  }

  .bchat__form {
    padding: 8px max(10px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }

  .bchat.kb .bchat__form {
    padding-bottom: 8px;
  }

  .bchat.kb .bchat__quick {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bchat__fab,
  .bchat__chip,
  .bchat__back,
  .bchat__close {
    transition: none;
  }

  .bchat__fab:hover {
    transform: none;
  }

  .bchat__typing i {
    animation: none;
    opacity: 0.6;
  }
}
