/* BÄR SERVICE — виджет чата. Переменные берутся из style.css. */

/* display: flex/grid ниже перебил бы атрибут hidden — возвращаем ему силу */
.chat [hidden] { display: none !important; }

.chat { position: fixed; right: 26px; bottom: 26px; z-index: 900; font-family: var(--sans); }

/* ---------- Кнопка ---------- */
.chat__fab {
  display: flex; align-items: center; gap: 10px;
  background: var(--gold); color: #14120e; border: none; cursor: pointer;
  padding: 14px 22px; border-radius: 999px; font-family: inherit;
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
  transition: transform .4s var(--ease-out), box-shadow .4s;
}
.chat__fab:hover { transform: translateY(-2px); box-shadow: 0 18px 46px rgba(0, 0, 0, .55); }
.chat.is-open .chat__fab { transform: scale(.92); opacity: .85; }
.chat__badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px;
  background: #c96a6a; color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px;
}
.chat__fab { position: relative; }

/* ---------- Панель ---------- */
.chat__panel {
  position: absolute; right: 0; bottom: 72px; width: min(370px, calc(100vw - 36px));
  max-height: min(620px, calc(100vh - 130px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ink-2); color: var(--text);
  border: 1px solid rgba(201, 169, 106, .22); border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: chat-in .35s var(--ease-out);
}
@keyframes chat-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.chat__head {
  display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(201, 169, 106, .16);
}
.chat__title { display: block; font-family: var(--serif); font-size: 17px; color: var(--cream); font-weight: 400; }
.chat__sub { display: block; font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }
.chat__close {
  margin-left: auto; background: none; border: none; color: var(--text-dim);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.chat__close:hover { color: var(--cream); }

/* ---------- Форма первого сообщения ---------- */
.chat__start { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.chat__field { position: relative; display: block; margin-bottom: 20px; }
.chat__field input, .chat__field textarea {
  width: 100%; background: transparent; border: none; color: var(--cream);
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  padding: 10px 2px; font-family: inherit; font-size: 14px; outline: none; resize: none;
}
.chat__field input:focus, .chat__field textarea:focus { border-color: var(--gold); }
.chat__field span {
  position: absolute; left: 2px; top: 10px; color: var(--text-dim); font-size: 14px;
  pointer-events: none; transition: transform .3s var(--ease-out), font-size .3s, color .3s;
  transform-origin: left top;
}
.chat__field input:focus + span, .chat__field input:not(:placeholder-shown) + span,
.chat__field textarea:focus + span, .chat__field textarea:not(:placeholder-shown) + span {
  transform: translateY(-16px); font-size: 11px; color: var(--gold); letter-spacing: .08em;
}
.chat__submit {
  background: var(--gold); color: #14120e; border: none; border-radius: 999px;
  padding: 13px; font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
}
.chat__submit:disabled { opacity: .5; cursor: default; }
.chat__legal { font-size: 11.5px; color: rgba(150, 145, 135, .85); margin-top: 14px; line-height: 1.5; }
.chat__legal a { color: var(--gold); }

/* ---------- Лента ---------- */
.chat__log {
  flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(201, 169, 106, .3) transparent;
}
.chat__msg { max-width: 84%; display: flex; flex-direction: column; gap: 4px; }
.chat__msg p {
  padding: 11px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.chat__msg time { font-size: 10.5px; color: rgba(233, 228, 218, .38); }
.chat__msg--out { align-self: flex-end; align-items: flex-end; }
.chat__msg--out p { background: rgba(201, 169, 106, .16); color: var(--cream); border-bottom-right-radius: 3px; }
.chat__msg--in { align-self: flex-start; }
.chat__msg--in p { background: rgba(255, 255, 255, .06); border-bottom-left-radius: 3px; }
.chat__note {
  align-self: center; text-align: center; font-size: 11.5px; color: var(--text-dim);
  background: rgba(255, 255, 255, .04); padding: 8px 14px; border-radius: 999px; max-width: 90%;
}

/* ---------- Ввод ---------- */
.chat__compose {
  display: flex; align-items: flex-end; gap: 10px; padding: 14px 16px;
  border-top: 1px solid rgba(201, 169, 106, .16);
}
.chat__compose textarea {
  flex: 1; background: rgba(255, 255, 255, .05); border: 1px solid transparent;
  border-radius: 14px; padding: 11px 14px; color: var(--cream);
  font-family: inherit; font-size: 14px; resize: none; outline: none; max-height: 120px;
}
.chat__compose textarea:focus { border-color: rgba(201, 169, 106, .4); }
.chat__compose button {
  width: 40px; height: 40px; flex: none; border: none; border-radius: 50%;
  background: var(--gold); color: #14120e; cursor: pointer; display: grid; place-items: center;
}

.chat__foot {
  display: flex; gap: 14px; padding: 0 16px 14px; flex-wrap: wrap;
}
.chat__foot button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-family: inherit; font-size: 11.5px; text-decoration: underline; padding: 0;
}
.chat__foot button:hover { color: var(--gold); }

@media (max-width: 520px) {
  .chat { right: 16px; bottom: 16px; }
  .chat__fab-label { display: none; }
  .chat__fab { padding: 15px; }
  .chat__panel { bottom: 66px; max-height: calc(100vh - 110px); }
}

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

/* ---------- Баннер согласия на статистику ---------- */
.consent {
  position: fixed; left: 26px; bottom: 26px; z-index: 950;
  width: min(400px, calc(100vw - 36px));
  background: var(--ink-2); color: var(--text);
  border: 1px solid rgba(201, 169, 106, .22); border-radius: 6px;
  padding: 22px 22px 18px; font-family: var(--sans);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  animation: chat-in .4s var(--ease-out);
}
.consent__text { font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.consent__actions { display: flex; gap: 10px; margin-top: 18px; }
.consent__btn {
  flex: 1; padding: 11px 14px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; border: 1px solid rgba(201, 169, 106, .35);
  background: none; color: var(--cream);
}
.consent__btn--yes { background: var(--gold); border-color: var(--gold); color: #14120e; }
.consent__btn:hover { border-color: var(--gold); }
.consent__more { display: inline-block; margin-top: 14px; font-size: 11.5px; color: var(--gold); }

@media (max-width: 700px) {
  .consent { left: 16px; right: 16px; bottom: 96px; width: auto; }
}
@media (prefers-reduced-motion: reduce) { .consent { animation: none; } }
