@charset "UTF-8";

/* ==========================================================================
   Консультант. Не пузырь-«поболтать», а компактная панель у края экрана:
   тон технической консоли, но читаемый и спокойный.
   ========================================================================== */

.chat-launch {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: var(--r-lg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px rgba(13, 21, 25, 0.55);
  transition: background-color 0.15s;
}
.chat-launch:hover { background: #17242b; }
.chat-launch__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--supply);
  flex-shrink: 0;
}
.chat-launch[hidden] { display: none; }

.chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  /* Выше cookie-баннера (150): иначе баннер перехватывает клики по кнопке
     отправки, а на телефоне ложится поверх поля ввода. */
  z-index: 170;
  width: min(400px, calc(100vw - 2.5rem));
  height: min(600px, calc(100vh - 2.5rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 50px -18px rgba(13, 21, 25, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat.is-open { display: flex; }

.chat__head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: var(--ink);
  color: #fff;
  flex-shrink: 0;
}
.chat__title { font-size: 0.9375rem; font-weight: 600; line-height: 1.25; }
.chat__sub {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  color: #8ea0aa;
}
.chat__actions { margin-left: auto; display: flex; gap: 0.25rem; }
.chat__icon {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: var(--r);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}
.chat__icon:hover { background: rgba(255,255,255,0.12); }

.chat__log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface-2);
}

.msg {
  max-width: 88%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-lg);
  font-size: 0.9375rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: var(--r);
  color: var(--ink);
}
.msg--user {
  align-self: flex-end;
  background: var(--return);
  color: #fff;
  border-bottom-right-radius: var(--r);
}
.msg--note {
  align-self: center;
  background: transparent;
  color: var(--ink-3);
  font-size: var(--t-sm);
  text-align: center;
  max-width: 100%;
  padding: 0.35rem 0;
}
.msg a { color: inherit; text-decoration: underline; }
.msg--bot a { color: var(--return); }

.chat__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 0.85rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
}
.chat__typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: blink 1.3s infinite ease-in-out;
}
.chat__typing span:nth-child(2) { animation-delay: 0.18s; }
.chat__typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 70%, 100% { opacity: 0.25; }
  35% { opacity: 1; }
}

/* Атрибут hidden обязан перебивать display: flex, иначе подсказки
   остаются на экране после первого вопроса. */
.chat__chips[hidden] { display: none; }

.chat__chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0 1rem 0.75rem;
  background: var(--surface-2);
}
.chat__chip {
  font: inherit;
  font-size: var(--t-sm);
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
}
.chat__chip:hover { border-color: var(--return); color: var(--return); }

.chat__form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.chat__input {
  flex: 1;
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  resize: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.45;
}
.chat__input:focus {
  outline: none;
  border-color: var(--return);
  box-shadow: 0 0 0 3px var(--return-tint);
}
.chat__send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  background: var(--supply);
  color: #fff;
  border: 0;
  border-radius: var(--r);
  cursor: pointer;
  padding: 0;
}
.chat__send:hover { background: var(--supply-dk); }
.chat__send[disabled] { background: var(--line); cursor: not-allowed; }

.chat__legal {
  padding: 0 0.75rem 0.7rem;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--ink-3);
  background: var(--surface);
}
.chat__legal a { color: var(--ink-3); }

@media (max-width: 520px) {
  .chat {
    right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .chat-launch { right: 1rem; bottom: 1rem; }
}

/* ==========================================================================
   Аватар, счётчик и приглашение.
   Раньше кнопка была плоской надписью и терялась на странице — посетитель
   просто не замечал, что консультант есть.
   ========================================================================== */

.chat-launch { padding: 0.55rem 1.1rem 0.55rem 0.6rem; gap: 0.65rem; }

.chat-launch__ava {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
}

.chat-launch__badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  background: var(--supply);
  color: #fff;
  border: 2px solid var(--surface);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
}
.chat-launch__badge[hidden] { display: none; }
.chat-launch { position: fixed; }

/* Мягкая пульсация привлекает внимание, но не дёргается без конца */
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(191, 42, 27, 0.45); }
  70%  { box-shadow: 0 0 0 12px rgba(191, 42, 27, 0); }
  100% { box-shadow: 0 0 0 0 rgba(191, 42, 27, 0); }
}
.chat-launch__ava { animation: pulse-ring 2.6s ease-out 3; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) {
  .chat-launch__ava { animation: none; }
}

/* Всплывающая подсказка над кнопкой */
.chat-invite {
  position: fixed;
  right: 1.25rem;
  bottom: 5.1rem;
  z-index: 121;
  width: min(290px, calc(100vw - 2.5rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--return);
  border-radius: var(--r-lg);
  box-shadow: 0 14px 34px -14px rgba(13, 21, 25, 0.45);
  padding: 0.9rem 2rem 0.9rem 1rem;
  cursor: pointer;
  animation: invite-in 0.35s ease-out;
}
.chat-invite[hidden] { display: none; }

@keyframes invite-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.chat-invite__text {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink-2);
}
.chat-invite__close {
  position: absolute;
  top: 0.35rem; right: 0.4rem;
  width: 24px; height: 24px;
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  border-radius: var(--r);
}
.chat-invite__close:hover { background: var(--surface-2); color: var(--ink); }

/* Аватар в шапке панели с точкой «на связи» */
.chat__ava { position: relative; flex-shrink: 0; display: block; }
.chat__online {
  position: absolute;
  right: 0; bottom: 1px;
  width: 10px; height: 10px;
  background: #2f9e5f;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

@media (max-width: 520px) {
  .chat-invite { right: 1rem; bottom: 4.8rem; }
  .chat-launch__text { display: none; }
  .chat-launch { padding: 0.5rem; border-radius: 999px; }
}
