/*!
 * Чат-ассистент «Мастер на связи» — стили виджета. Версия пакета 2026-10-18.
 * Всё под префиксом .nchat-, чтобы ничего не столкнулось со стилями сайта.
 * Цвета и высота кнопки — переменные ниже: под сайт правятся только они
 * (или переопределяются в CSS сайта).
 */

:root {
  --nchat-accent: #e75440;        /* кнопка и «отправить» */
  --nchat-accent-hover: #cf4430;
  --nchat-head: #3f9ad4;          /* шапка панели и реплики человека */
  --nchat-link: #2684c0;
  --nchat-focus: #1b4f77;
  /* кнопка поднята: внизу справа у сайтов nadomu.* свои красные кнопки */
  --nchat-btn-bottom: 88px;
  --nchat-btn-bottom-mobile: 76px;
}

.nchat-btn {
  position: fixed;
  right: 20px;
  bottom: var(--nchat-btn-bottom);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 3px;
  background: var(--nchat-accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
}
.nchat-btn:hover { background: var(--nchat-accent-hover); }
.nchat-btn:focus-visible { outline: 3px solid var(--nchat-focus); outline-offset: 2px; }
.nchat-btn-i { font-size: 17px; line-height: 1; }
.nchat-hidden { display: none; }

.nchat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 370px;
  max-width: calc(100vw - 32px);
  max-height: min(620px, calc(100vh - 40px));
  max-height: min(620px, calc(100dvh - 40px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 44px rgba(0, 0, 0, .26);
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: #2b2f33;
  text-align: left;
}
.nchat-panel.nchat-open { display: flex; }

.nchat-head {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  background: var(--nchat-head);
  color: #fff;
}
.nchat-head b { font-size: 15px; font-weight: 600; }
.nchat-x {
  margin-left: auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.nchat-x:hover { background: rgba(255, 255, 255, .16); }
.nchat-x:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.nchat-log {
  flex: 1;
  min-height: 220px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f4f5f6;
}

.nchat-msg {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 14.5px;
}
.nchat-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e4e7;
  border-bottom-left-radius: 4px;
}
.nchat-me {
  align-self: flex-end;
  background: var(--nchat-head);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.nchat-note {
  align-self: center;
  max-width: 100%;
  padding: 3px 0;
  background: none;
  color: #2f7d4f;
  font-size: 13px;
  font-weight: 600;
}

.nchat-typing { display: flex; gap: 4px; padding: 13px; }
.nchat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a3a8ad;
  animation: nchat-blink 1.2s infinite;
}
.nchat-typing i:nth-child(2) { animation-delay: .18s; }
.nchat-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes nchat-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.nchat-form {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 11px 14px;
  border-top: 1px solid #e2e4e7;
  background: #fff;
}
.nchat-form input {
  flex: 1;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid #d5d8dc;
  border-radius: 3px;
  background: #f4f5f6;
  color: #2b2f33;
  font: inherit;
  font-size: 15px;
  box-shadow: none;
}
.nchat-form input:focus-visible { outline: 2px solid var(--nchat-head); outline-offset: 1px; border-color: var(--nchat-head); }
.nchat-form input:disabled { opacity: .6; }

.nchat-send {
  flex: none;
  width: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--nchat-accent);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
}
.nchat-send:hover { background: var(--nchat-accent-hover); }
.nchat-send:disabled { opacity: .45; cursor: default; }
.nchat-send:focus-visible { outline: 2px solid var(--nchat-focus); outline-offset: 2px; }

.nchat-foot {
  padding: 0 14px 12px;
  background: #fff;
  color: #6b7075;
  font-size: 11.5px;
  line-height: 1.45;
}
.nchat-foot a { color: var(--nchat-link); font-weight: 600; }

/* Кнопки районов под вопросом «В каком районе…» */
.nchat-chips {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}
.nchat-chip {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--nchat-head);
  border-radius: 14px;
  background: #fff;
  color: var(--nchat-link);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.3;
  cursor: pointer;
}
.nchat-chip:hover { background: var(--nchat-head); color: #fff; }
.nchat-chip:focus-visible { outline: 2px solid var(--nchat-focus); outline-offset: 1px; }
.nchat-chip-other { border-style: dashed; border-color: #a3a8ad; color: #4a4f54; }
.nchat-chip-other:hover { background: #eef0f2; color: #2b2f33; }

@media (max-width: 520px) {
  .nchat-panel {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .nchat-btn {
    right: 14px;
    bottom: calc(var(--nchat-btn-bottom-mobile) + env(safe-area-inset-bottom, 0px));
    padding: 11px 16px;
    font-size: 14px;
  }
  /* iPhone увеличивает страницу при фокусе на поле со шрифтом меньше 16px */
  .nchat-form input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .nchat-typing i { animation: none; opacity: .55; }
}
