/* Client chat floating panel — additive, does not change site layout */

/* Отдельный экран /chat.html — тот же вид панели, без каталога под ним */
html.kt-chat-page .kt-chat-fab,
html.kt-chat-page .kt-staff-fab {
  display: none !important;
}
.kt-chat-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: #e85d04;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  text-align: center;
  padding: 8px;
  white-space: pre-line;
}
.kt-chat-fab:hover { filter: brightness(1.05); }

/* Сотрудники — отдельная кнопка над оранжевым клиентским чатом */
.kt-staff-fab {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 90;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(125, 222, 203, 0.45);
  background: #1a3a4a;
  color: #7ddecb;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.kt-staff-fab:hover { filter: brightness(1.08); }
.kt-staff-chat-panel {
  bottom: 148px;
}
.kt-chat-fab .kt-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #7ddecb;
  border: 2px solid #0a1a1f;
  color: #0a1a1f;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 0 0 0 rgba(125, 222, 203, 0.65);
  line-height: 1;
}
/* display:flex иначе перекрывает HTML hidden — бейдж «0» торчал всегда */
.kt-chat-fab .kt-chat-badge[hidden] {
  display: none !important;
}
.kt-chat-fab .kt-chat-badge.is-live {
  animation: kt-chat-badge-pulse 1.15s ease-in-out infinite;
}
@keyframes kt-chat-badge-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(125, 222, 203, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 10px 4px rgba(125, 222, 203, 0.45);
    transform: scale(1.1);
  }
}
/* Как мессенджер админки (org-cascade-chat) */
.kt-chat-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 91;
  width: min(400px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 100px));
  max-height: min(640px, calc(100vh - 100px));
  background: #0c1016;
  color: #e8eef4;
  border: 1px solid rgba(102, 255, 227, 0.18);
  border-radius: 16px;
  box-shadow:
    0 0 28px rgba(102, 255, 227, 0.06),
    0 18px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
}
.kt-chat-panel[hidden] { display: none !important; }
.kt-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #0c1016;
  flex: 0 0 auto;
}
.kt-chat-head strong {
  font-size: 0.82rem;
  font-weight: 700;
}
.kt-chat-head p {
  margin: 2px 0 0;
  color: #8a9296;
  font-size: 0.72rem;
  font-weight: 600;
}
.kt-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #e8eef4;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  flex: 0 0 auto;
}
/* Быстрые вкладки Чат / Каталог — как в админке */
.kt-chat-mobile-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  flex: 0 0 auto;
  background: #0b1018;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.kt-chat-mobile-tab {
  min-height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #121820;
  color: #8a9296;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
}
.kt-chat-mobile-tab.is-active {
  color: #0b1018;
  background: #7ddecb;
  border-color: #7ddecb;
}
.kt-chat-body {
  padding: 0;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0c1016;
}
.kt-chat-body label {
  display: block;
  font-size: 0.78rem;
  color: #8a9296;
  margin: 10px 0 5px;
  font-weight: 600;
}
.kt-chat-body input,
.kt-chat-body select,
.kt-chat-body textarea,
.kt-chat-body button {
  font: inherit;
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1419;
  color: #e8eef4;
  padding: 10px 12px;
  box-sizing: border-box;
}
.kt-chat-body input:focus,
.kt-chat-body select:focus,
.kt-chat-body textarea:focus {
  outline: none;
  border-color: rgba(102, 255, 227, 0.7);
  box-shadow: 0 0 0 1px rgba(102, 255, 227, 0.25), 0 0 14px rgba(102, 255, 227, 0.18);
}
#ktChatAskForm,
#ktChatBody > form {
  padding: 10px 12px 12px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
/* Keep the composer visible instead of letting the message list shrink it. */
#ktChatBody > form.kt-chat-compose {
  flex: 0 0 auto;
  min-height: max-content;
  overflow: visible;
}
.kt-chat-body button[type="submit"],
.kt-chat-body .kt-chat-primary {
  background: #e85d04;
  border: none;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.kt-chat-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.kt-chat-tabs button {
  background: transparent;
  border: 1px solid #2c3845;
  color: #8b9aab;
  cursor: pointer;
  font-weight: 600;
}
.kt-chat-tabs button.is-active {
  color: #fff;
  border-color: #e85d04;
  background: rgba(232, 93, 4, 0.18);
}
.kt-chat-err { color: #ffb4a2; font-size: 0.85rem; margin-top: 8px; }
.kt-chat-ok { color: #7ddecb; font-size: 0.85rem; margin-top: 8px; }
.kt-chat-muted { color: #8b9aab; font-size: 0.85rem; }
.kt-chat-link {
  display: inline-block;
  margin-top: 10px;
  color: #7eb8ff;
  font-size: 0.85rem;
}
.kt-chat-msglist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
  background: #0c1016;
}
/* Пузыри как .org-cascade-msg */
.kt-chat-bubble {
  align-self: flex-start;
  max-width: 92%;
  background: #1a222c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.kt-chat-bubble.is-mine {
  align-self: flex-end;
  background: rgba(102, 255, 227, 0.08);
  border-color: rgba(102, 255, 227, 0.28);
}
.kt-chat-bubble small {
  display: block;
  color: #8a9296;
  font-size: 0.68rem;
  margin-bottom: 4px;
}
.kt-chat-bubble-text {
  color: #e8eef4;
}
/* Композер как .org-cascade-form — без горизонтального ползунка */
.kt-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b1018;
  margin: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.kt-chat-compose textarea {
  min-height: 44px !important;
  max-height: 100px;
  height: 44px;
  resize: none;
  margin: 0;
  font-size: 0.85rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1419;
  color: #e8eef4;
  padding: 10px 12px;
}
.kt-chat-compose textarea:focus {
  outline: none;
  border-color: rgba(102, 255, 227, 0.7);
  box-shadow: 0 0 0 1px rgba(102, 255, 227, 0.25), 0 0 14px rgba(102, 255, 227, 0.18);
}
/* перебиваем .kt-chat-body button { width:100% } — иначе кнопка раздувает ряд и появляется ползунок */
.kt-chat-compose button,
.kt-chat-body .kt-chat-compose button {
  width: auto !important;
  min-width: 96px;
  max-width: none;
  flex-shrink: 0;
  min-height: 44px;
  height: 44px;
  background: #e85d04;
  border: none;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
  padding: 0 14px;
  align-self: end;
  box-sizing: border-box;
}
/* Подвал под композером — компактно как в админке */
.kt-chat-body > .kt-chat-muted {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 10px 10px;
  border-top: 0;
  background: #0b1018;
  font-size: 0.72rem;
}
.kt-chat-body > .kt-chat-err {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 10px 6px;
  background: #0b1018;
}
.kt-chat-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.kt-chat-textbtn {
  display: inline;
  width: auto;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: #7eb8ff;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}
.kt-chat-hr {
  border: none;
  border-top: 1px solid #2c3845;
  margin: 0 0 12px;
}
/* Пока чат открыт — страница не скроллится под ним */
html.kt-chat-open,
body.kt-chat-open {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}
body.kt-chat-open .kt-chat-msglist {
  touch-action: pan-y;
}
@media (max-width: 640px) {
  .kt-chat-fab { right: 12px; bottom: 12px; }
  .kt-staff-fab { right: 16px; bottom: 78px; }
  /* Окно = visualViewport; композер зафиксирован внизу, без бокового скролла */
  .kt-chat-panel:not([hidden]) {
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    z-index: 12050;
    background: #0c1016;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
  }
  .kt-staff-chat-panel { bottom: 138px; }
  .kt-chat-head,
  .kt-chat-mobile-tabs {
    flex: 0 0 auto;
  }
  .kt-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .kt-chat-msglist {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    gap: 3px;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .kt-chat-bubble {
    max-width: 88%;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  .kt-chat-compose {
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
    margin-top: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .kt-chat-compose textarea {
    min-height: 36px !important;
    height: 36px;
    /* iOS Safari зумит страницу, если в поле < 16px */
    font-size: 16px !important;
  }
  .kt-chat-body input,
  .kt-chat-body textarea,
  #ktChatAskForm input,
  #ktChatAskForm textarea {
    font-size: 16px !important;
  }
  .kt-chat-compose button,
  .kt-chat-body .kt-chat-compose button {
    min-height: 36px;
    height: 36px;
    min-width: 72px;
    width: auto !important;
    padding: 0 10px;
  }
  .kt-chat-panel:not([hidden]) .kt-chat-body > .kt-chat-muted {
    display: none !important;
  }
  .kt-chat-row2 { grid-template-columns: 1fr; }
}


/* messenger rich car link cards */
.kt-msg-link {
  color: #ff8752;
  text-decoration: underline;
  text-decoration-color: rgba(255, 135, 82, 0.72);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  background: rgba(255, 106, 42, 0.08);
  border-radius: 4px;
  padding: 0 3px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}
.kt-msg-link:hover,
.kt-msg-link:focus-visible {
  color: #66ffe3;
  text-decoration-color: currentColor;
}
.kt-msg-linkcard {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 106, 42, 0.46);
  border-left: 3px solid #ff6a2a;
  background: linear-gradient(145deg, rgba(255, 106, 42, 0.09), #121820 48%, rgba(102, 255, 227, 0.045));
  color: inherit;
  text-decoration: none !important;
  max-width: 320px;
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.kt-msg-linkcard:hover,
.kt-msg-linkcard:focus-visible {
  border-color: rgba(102, 255, 227, 0.72);
  box-shadow: 0 0 16px rgba(102, 255, 227, 0.12);
  outline: none;
}
.kt-msg-linkcard-site {
  display: block;
  font-size: 0.72rem;
  color: #7de0ce;
  margin-bottom: 4px;
}
.kt-msg-linkcard-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f2f4f7;
  margin-bottom: 4px;
  line-height: 1.25;
}
.kt-msg-linkcard-desc {
  display: block;
  font-size: 0.78rem;
  color: #a8b4c8;
  line-height: 1.35;
  margin-bottom: 8px;
}
.kt-msg-linkcard-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #0b1018;
}
.kt-msg-linkcard-img.is-empty { min-height: 72px; }
.kt-msg-linkcard.is-loading { opacity: 0.75; }
.msg-bubble-text .kt-msg-linkcard,
.kt-chat-bubble .kt-msg-linkcard,
.org-msg-text .kt-msg-linkcard { margin-top: 8px; }

