/* Окно «Вопрос менеджеру» (public/support-chat.js). */
.support-chat {
  position: fixed;
  z-index: 150;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-size: var(--text-sm, 14px);
}

.support-chat__launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--blue, #1f5fbf);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow, 0 14px 30px rgba(17, 24, 35, 0.2));
}

.support-chat__launcher:hover { background: var(--blue-dark, #17499a); }
.support-chat__launcher:focus-visible,
.support-chat__close:focus-visible { outline: 3px solid #ffb400; outline-offset: 2px; }

.support-chat__launcher-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-weight: 700;
}

.support-chat__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.support-chat__badge[hidden],
.support-chat__panel[hidden],
.support-chat__form[hidden],
.support-chat__thread[hidden],
.support-chat__error[hidden] { display: none; }

.support-chat__panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(600px, calc(100dvh - 110px));
  overflow: hidden;
  border: 1px solid var(--line, #e3e8ee);
  border-radius: var(--radius-lg, 16px);
  background: var(--surface, #fff);
  color: var(--ink, #111823);
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(17, 24, 35, 0.2));
}

.support-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--blue, #1f5fbf);
  color: #fff;
}

.support-chat__head-text { display: grid; gap: 2px; }
.support-chat__head-text span { font-size: 12px; opacity: 0.85; }

.support-chat__close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.support-chat__form {
  display: grid;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}

.support-chat__field { display: grid; gap: 4px; }
.support-chat__field > span { color: var(--muted, #59636f); font-size: 13px; }

.support-chat__field input,
.support-chat__field textarea,
.support-chat__reply textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong, #cfd6df);
  border-radius: var(--radius-sm, 8px);
  background: #fff;
  color: inherit;
  font: inherit;
  /* 16px — иначе iPhone приближает страницу при вводе. */
  font-size: 16px;
  resize: none;
}

.support-chat__field input:focus,
.support-chat__field textarea:focus,
.support-chat__reply textarea:focus { outline: 2px solid var(--blue, #1f5fbf); outline-offset: 0; }

.support-chat__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.support-chat__consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted, #59636f);
  font-size: 12px;
  line-height: 1.4;
}

.support-chat__consent input { margin-top: 2px; }
.support-chat__consent a { color: var(--blue, #1f5fbf); }

.support-chat__error {
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.support-chat__submit {
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  background: var(--blue, #1f5fbf);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.support-chat__submit:disabled,
.support-chat__send:disabled { opacity: 0.6; cursor: default; }

.support-chat__thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.support-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-soft, #fafbfc);
}

.support-chat__message {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line, #e3e8ee);
  overflow-wrap: anywhere;
}

.support-chat__message p { margin: 0; white-space: pre-wrap; line-height: 1.4; }

.support-chat__message--customer {
  align-self: flex-end;
  border-color: transparent;
  background: var(--blue-soft, #eaf1fc);
}

.support-chat__message--manager { border-color: var(--blue, #1f5fbf); }

.support-chat__message--system {
  align-self: center;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted, #59636f);
  font-size: 13px;
  text-align: center;
}

.support-chat__message--typing p { color: var(--muted, #59636f); font-style: italic; }

.support-chat__who {
  display: block;
  margin-bottom: 2px;
  color: var(--muted, #59636f);
  font-size: 12px;
  font-weight: 600;
}

.support-chat__link {
  display: block;
  margin-top: 6px;
  color: var(--blue, #1f5fbf);
  font-weight: 600;
}

.support-chat__thread > .support-chat__error { padding: 6px 14px 0; }

.support-chat__reply {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line, #e3e8ee);
}

.support-chat__send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--blue, #1f5fbf);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.support-chat__restart {
  padding: 0 14px 12px;
  border: 0;
  background: transparent;
  color: var(--muted, #59636f);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-align: left;
  cursor: pointer;
}

@media (max-width: 720px) {
  /* Над нижней панелью навигации. */
  .support-chat {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .support-chat__launcher { padding: 0 10px; }
  .support-chat__launcher-text { display: none; }
  .support-chat--open .support-chat__launcher { display: none; }

  .support-chat__panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 100px - env(safe-area-inset-bottom, 0px));
  }
}

@media print {
  .support-chat { display: none; }
}
