/* Окно «Менеджер ответит» (js/chat.js): как переписка с живым менеджером - аватар-логотип, «онлайн» / «печатает…»,
   галочки «отправлено / прочитано», время у сообщений, точечный узор фона, плавное появление.
   Подключается после sayt.css и перекрывает его старые правила чата. Оранжевый - только акценты: кнопка «Отправить»,
   счётчик новых, «печатает», прочитанные галочки. */

/* ---------- кнопка и подсказка над ней */
.chat-kn .chat-schet { position: absolute; top: 7px; right: 7px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--oranzh); color: #1f1a12; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--grafit); animation: chat-pop 0.3s cubic-bezier(.2,.8,.2,1); }
.chat-kn .chat-schet[hidden] { display: none; }
.chat-kn:has(.chat-schet:not([hidden])) .chat-tochka { display: none; }
.chat-prevyu { position: absolute; right: 0; bottom: calc(100% + 12px); width: max-content; max-width: 270px; display: grid; gap: 2px;
  padding: 11px 14px 12px; border: 0; border-radius: 16px 16px 6px 16px; background: var(--bel); color: var(--tekst); text-align: left;
  font: inherit; box-shadow: 0 0 0 1px rgba(60, 40, 15, 0.06), 0 14px 36px rgba(40, 25, 10, 0.18); cursor: pointer;
  animation: chat-pop 0.35s cubic-bezier(.2,.8,.2,1); }
.chat-prevyu[hidden], .chat.otkryt .chat-prevyu { display: none; }
.chat-prevyu b { font-size: 12px; font-weight: 800; color: var(--tekst-2); }
.chat-prevyu span { font-size: 14px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- окно */
.chat-okno { width: 384px; height: min(620px, calc(100vh - 110px)); border-radius: 24px; background: var(--bel);
  box-shadow: 0 0 0 1px rgba(60, 40, 15, 0.07), 0 24px 70px rgba(40, 25, 10, 0.28);
  opacity: 0; transform: translateY(14px) scale(0.97); transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.3s cubic-bezier(.2,.8,.2,1); }
.chat-okno.vidno { opacity: 1; transform: none; }

.chat-shapka { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; background: var(--grafit); color: #fff; }
.chat-ava { position: relative; flex: none; width: 44px; height: 44px; }
.chat-ava img { width: 44px; height: 44px; border-radius: 50%; background: #fff; object-fit: cover; display: block; }
.chat-ava i { position: absolute; right: -1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #4caf50; box-shadow: 0 0 0 2.5px var(--grafit); }
.chat-kto { min-width: 0; display: grid; gap: 2px; }
.chat-kto b { font-size: 15px; font-weight: 800; line-height: 1.25; letter-spacing: -0.005em; }
.chat-shapka .chat-status { font-size: 12.5px; font-weight: 700; color: #8fd99a; transition: color 0.2s; }
.chat-shapka .chat-status.pech { color: var(--oranzh); }
.chat-zakr { margin-left: auto; flex: none; width: 36px; height: 36px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.08);
  color: #fff; display: grid; place-items: center; font-size: 0; transition: background 0.15s; }
.chat-zakr:hover { background: rgba(255, 255, 255, 0.16); }
.chat-zakr svg { width: 18px; height: 18px; }

/* ---------- переписка: бежевый фон с точечным узором */
.chat-spisok { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 14px 12px; display: flex; flex-direction: column; gap: 6px;
  background-color: var(--bezh); background-image: radial-gradient(rgba(34, 30, 26, 0.075) 1px, transparent 1.4px); background-size: 16px 16px; }
.chat-s { position: relative; max-width: 84%; padding: 9px 12px 7px 13px; border-radius: 18px; font-size: 14.5px; font-weight: 600; line-height: 1.45;
  box-shadow: none; overflow-wrap: anywhere; }
.chat-s + .chat-s-ya, .chat-s-m + .chat-s-m { margin-top: 0; }
.chat-s-ya + .chat-s-m, .chat-s-m + .chat-s-ya { margin-top: 6px; }
.chat-s-m { align-self: flex-start; background: var(--bel); color: var(--tekst); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(60, 40, 15, 0.07); }
.chat-s-ya { align-self: flex-end; background: var(--grafit); color: #fff; border-bottom-right-radius: 6px; }
.chat-s a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1.5px; }
.chat-s-m a { text-decoration-color: var(--oranzh); }
.chat-s b { font-weight: 800; }
.chat-tekst { display: inline; }
.chat-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -2px 10px; font-size: 11px; font-weight: 600; line-height: 1;
  color: var(--tekst-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-s-ya .chat-meta { color: rgba(255, 255, 255, 0.6); }
.chat-galki { width: 17px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-galki.dve { color: var(--oranzh); }
.chat-s.novoe { animation: chat-pop 0.3s cubic-bezier(.2,.8,.2,1); }
.chat-s-ya.novoe { transform-origin: bottom right; }
.chat-s-m.novoe { transform-origin: bottom left; }

.chat-pech { display: flex; gap: 4px; align-items: center; padding: 13px 14px; min-height: 0; }
.chat-pech i { width: 7px; height: 7px; border-radius: 50%; background: var(--tekst-3); animation: chat-tochki 1.2s ease-in-out infinite; }
.chat-pech i:nth-child(2) { animation-delay: 0.15s; }
.chat-pech i:nth-child(3) { animation-delay: 0.3s; }
.chat-sist { align-self: center; max-width: 90%; margin: 4px 0; padding: 5px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.7);
  font-size: 12.5px; font-weight: 600; color: var(--tekst-2); text-align: center; }
.chat-svyaz { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.chat-svyaz a { text-decoration: none !important; background: var(--bezh); border-radius: 9px; padding: 3px 10px; font-weight: 700; }

/* ---------- быстрые вопросы */
.chat-bystro { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 0 14px; background: var(--bezh); }
.chat-bystro:not(:empty) { padding-bottom: 12px; }
.chat-chip { height: auto; min-height: 34px; padding: 7px 13px; border: 0; border-radius: 14px; background: var(--bel); color: var(--tekst);
  font: inherit; font-size: 13.5px; font-weight: 700; line-height: 1.25; text-align: left; box-shadow: inset 0 0 0 1.5px var(--liniya);
  cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.12s; animation: chat-pop 0.35s cubic-bezier(.2,.8,.2,1) both; }
.chat-chip:nth-child(2) { animation-delay: 0.05s; } .chat-chip:nth-child(3) { animation-delay: 0.1s; } .chat-chip:nth-child(4) { animation-delay: 0.15s; }
.chat-chip:hover { background: var(--grafit); color: #fff; box-shadow: none; }
.chat-chip:active { transform: scale(0.97); }

/* ---------- поле */
.chat-forma { display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 12px; border-top: 1px solid var(--liniya); background: var(--bel); }
.chat-forma textarea { flex: 1; min-width: 0; height: 44px; max-height: 120px; resize: none; border: 0; border-radius: 14px; background: var(--bezh);
  padding: 11px 14px; font: inherit; font-weight: 600; font-size: 15px; line-height: 22px; color: var(--tekst); outline: none; overflow-y: auto; }
.chat-forma textarea::placeholder { color: var(--tekst-3); }
.chat-forma textarea:focus { box-shadow: 0 0 0 2px var(--oranzh); background: var(--bel); }
.chat-forma button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--oranzh); color: #1f1a12; display: grid; place-items: center;
  transition: transform 0.12s, background 0.15s; }
.chat-forma button:hover { background: var(--oranzh-2); }
.chat-forma button:active { transform: scale(0.92); }
.chat-forma button svg { width: 20px; height: 20px; }

@keyframes chat-pop { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes chat-tochki { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- телефон: окно на весь экран, как мессенджер */
@media (max-width: 560px) {
  .chat.otkryt { right: 0 !important; bottom: 0 !important; left: 0; top: 0; }
  .chat.otkryt .chat-okno { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; transform-origin: bottom center; }
  .chat-shapka { padding-top: max(14px, env(safe-area-inset-top, 0px)); }
  .chat-forma { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
  .chat-forma textarea { font-size: 16px; }
  .chat-s { max-width: 86%; }
  .chat-prevyu { max-width: calc(100vw - 100px); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-okno, .chat-okno.vidno { transition: none; transform: none; }
  .chat-s.novoe, .chat-chip, .chat-prevyu, .chat-kn .chat-schet { animation: none; }
  .chat-pech i { animation-duration: 2.4s; }
}
