/* «Быстрая связь» — окно чата с менеджером и «Перезвоните мне» (29.10.2026). Скрипт — portit-chat.js. */
#pit-chat {
  --pc-accent: var(--portit-accent, #F23534);
  --pc-dark: var(--portit-dark, #1d1f24);
  --pc-line: #e6ecf0;
  --pc-field: #d5dde3;
  --pc-muted: #6b7785;
  --pc-soft: #f4f6f8;
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 10060;
  display: flex;
  flex-direction: column;
  width: 372px;
  height: 600px;
  max-height: calc(100vh - 116px);
  border: 1px solid var(--pc-line);
  border-radius: 16px;
  background: #fff;
  color: var(--pc-dark);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 18px 48px rgba(29, 31, 36, 0.22);
  overflow: hidden;
  animation: pc-in 0.16s ease-out;
}

#pit-chat[hidden] {
  display: none;
}

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

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

#pit-chat *,
#pit-chat *::before,
#pit-chat *::after {
  box-sizing: border-box;
}

#pit-chat button {
  font: inherit;
  cursor: pointer;
}

.pc-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  background: var(--pc-dark);
  color: #fff;
}

.pc-ava {
  display: flex;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  height: 38px;
  border-radius: 50%;
  background: var(--pc-accent);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pc-hd {
  min-width: 0;
}

.pc-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.pc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 1.3;
}

.pc-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa4ae;
}

#pit-chat.is-on .pc-dot {
  background: #2ecc71;
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.22);
}

#pit-chat.is-busy .pc-dot {
  background: #f5a623;
}

.pc-x {
  display: inline-flex;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  height: 38px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 18px;
}

.pc-x:hover,
.pc-x:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.pc-links {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--pc-line);
}

.pc-links[hidden] {
  display: none;
}

.pc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--pc-line);
  border-radius: 999px;
  color: var(--pc-dark);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.pc-link:hover,
.pc-link:focus-visible {
  border-color: var(--pc-dark);
  color: var(--pc-dark);
  text-decoration: none;
}

.pc-link .fa-telegram {
  color: #229ed9;
  font-size: 15px;
}

.pc-link .fa-whatsapp {
  color: #25d366;
  font-size: 15px;
}

.pc-link .fa-phone,
.pc-link .fa-envelope {
  color: var(--pc-accent);
}

.pc-max {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, #4b6bff, #8a3ffc);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.pc-tabs {
  display: flex;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--pc-line);
}

.pc-tab {
  flex: 1 1 50%;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: #fff;
  color: var(--pc-muted);
  font-size: 13.5px;
  font-weight: 600;
}

.pc-tab.is-on {
  border-bottom-color: var(--pc-accent);
  color: var(--pc-dark);
}

.pc-pane {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.pc-pane[hidden] {
  display: none;
}

.pc-msgs {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 12px 6px;
  background: var(--pc-soft);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.pc-m {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 86%;
  margin: 0 0 8px;
}

.pc-m.in {
  align-items: flex-end;
  margin-left: auto;
}

.pc-a {
  margin: 0 0 2px 4px;
  color: var(--pc-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.pc-b {
  padding: 8px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pc-m.in .pc-b {
  border-bottom-right-radius: 4px;
  background: var(--pc-dark);
  color: #fff;
}

.pc-m.out .pc-b {
  border: 1px solid var(--pc-line);
  border-bottom-left-radius: 4px;
  background: #fff;
}

.pc-t {
  margin: 2px 4px 0;
  color: var(--pc-muted);
  font-size: 11px;
}

.pc-m.is-pending .pc-b {
  opacity: 0.6;
}

.pc-m.is-failed .pc-t {
  color: var(--pc-accent);
}

.pc-m.is-failed .pc-t button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  text-decoration: underline;
}

.pc-sys {
  margin: 6px 8px 10px;
  color: var(--pc-muted);
  font-size: 12px;
  text-align: center;
}

.pc-card {
  margin: 4px 0 10px;
  padding: 12px;
  border: 1px solid var(--pc-line);
  border-left: 3px solid var(--pc-accent);
  border-radius: 12px;
  background: #fff;
}

.pc-card p {
  margin: 0 0 8px;
  font-size: 13px;
}

.pc-f {
  display: block;
  width: 100%;
  height: 40px;
  margin: 0 0 8px;
  padding: 0 12px;
  border: 1px solid var(--pc-field);
  border-radius: 10px;
  background: #fff;
  color: var(--pc-dark);
  font-size: 14px;
}

textarea.pc-f {
  height: auto;
  min-height: 62px;
  padding: 8px 12px;
  resize: vertical;
}

.pc-f:focus,
.pc-input textarea:focus {
  border-color: var(--pc-dark);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(29, 31, 36, 0.08);
}

.pc-f.is-err {
  border-color: var(--pc-accent);
}

.pc-err {
  margin: -4px 0 8px;
  color: var(--pc-accent);
  font-size: 12px;
}

.pc-err[hidden] {
  display: none;
}

.pc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--pc-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.pc-btn:hover {
  background: #d92c2b;
}

.pc-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.pc-btn.pc-btn-ghost {
  border: 1px solid var(--pc-field);
  background: #fff;
  color: var(--pc-dark);
}

.pc-note {
  margin: 8px 0 0;
  color: var(--pc-muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.pc-note a {
  color: inherit;
  text-decoration: underline;
}

.pc-chips {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
  background: var(--pc-soft);
}

.pc-chips[hidden] {
  display: none;
}

.pc-chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--pc-field);
  border-radius: 999px;
  background: #fff;
  color: var(--pc-dark);
  font-size: 12.5px;
}

.pc-chip:hover {
  border-color: var(--pc-dark);
}

.pc-input {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--pc-line);
  background: #fff;
}

.pc-input textarea {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--pc-field);
  border-radius: 12px;
  color: var(--pc-dark);
  font-size: 14px;
  line-height: 1.4;
  resize: none;
}

.pc-send {
  display: inline-flex;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--pc-accent);
  color: #fff;
  font-size: 15px;
}

.pc-send:disabled {
  opacity: 0.5;
}

.pc-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

.pc-call {
  padding: 14px;
  overflow-y: auto;
}

.pc-call h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.pc-sub {
  margin: 0 0 12px;
  color: var(--pc-muted);
  font-size: 13px;
}

.pc-done {
  padding: 26px 8px;
  text-align: center;
}

.pc-done[hidden] {
  display: none;
}

.pc-done > i {
  color: #2ecc71;
  font-size: 40px;
}

.pc-done h3 {
  margin: 12px 0 6px;
}

.pc-done p {
  margin: 0 0 14px;
  color: var(--pc-muted);
}

/* кнопка в доке: открыто — крестик, «Перезвоните мне» прячем (есть вкладка в окне); непрочитанные — счётчик */
#portit-chat-fab {
  position: relative;
}

html.pit-chat-open #portit-chat-fab {
  background: linear-gradient(95deg, #f44336 20%, #424867 80%);
}

html.pit-chat-open #portit-fab {
  display: none;
}

#portit-chat-fab .pc-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--portit-accent, #F23534);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

#portit-chat-fab .pc-badge[hidden] {
  display: none;
}

/* планшет: окно снизу справа, док прячем — закрывается крестиком в окне; липкую шапку не перекрываем */
@media (max-width: 991px) {
  #pit-chat {
    right: 12px;
    bottom: 12px;
    width: min(400px, calc(100vw - 24px));
    max-height: calc(100vh - 88px);
    max-height: calc(100dvh - 88px);
  }

  html.pit-chat-open #portit-contact-dock {
    display: none !important;
  }
}

/* телефон: на весь экран (высота — по видимой области, когда открыта клавиатура: portit-chat.js) */
@media (max-width: 575px) {
  #pit-chat {
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  html.pit-chat-open,
  html.pit-chat-open body {
    overflow: hidden;
  }

  .pc-input textarea,
  .pc-f {
    font-size: 16px;
  }

  .pc-link {
    height: 32px;
  }
}
