/* Виджет чата + модалка дожима */

.qr-chat-root {
  --qr-chat-z: 12000;
  font-family: var(--font, "Inter", system-ui, sans-serif);
}

.qr-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--qr-chat-z);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--blue, #2E7DF6);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--sh-4, 0 24px 48px -12px rgba(0, 0, 0, .18));
}

.qr-chat-fab:hover { background: var(--blue-600, #1C63D4); }

.qr-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: calc(var(--qr-chat-z) + 1);
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--l-line, #D7DEE9);
  border-radius: 16px;
  box-shadow: var(--sh-4, 0 24px 48px -12px rgba(0, 0, 0, .22));
  overflow: hidden;
}

.qr-chat-panel[hidden],
.qr-chat-fab[hidden] { display: none !important; }

.qr-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--d-800, #0B1220);
  color: var(--t-on-dark, #F4F8FD);
}

.qr-chat-head strong { font-size: 15px; font-weight: 700; }
.qr-chat-head span { display: block; font-size: 12px; color: var(--t-on-dark-3, #9DB0C9); margin-top: 2px; }

.qr-chat-head button {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: .85;
}

.qr-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--l-bg, #F5F7FB);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qr-chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--t-on-light, #101828);
  white-space: pre-wrap;
  word-break: break-word;
}

.qr-chat-bubble.assistant,
.qr-chat-bubble.operator {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--l-line, #D7DEE9);
}

.qr-chat-bubble.operator { border-color: #86EFAC; }

.qr-chat-bubble.visitor {
  align-self: flex-end;
  background: #E8F1FE;
  border: 1px solid #C5D9F8;
}

.qr-chat-bubble.system {
  align-self: center;
  background: var(--amber-soft, #FEF6E6);
  border: 1px solid #F0D9A0;
  font-size: 13px;
  color: var(--amber-ink, #8A5A00);
}

.qr-chat-foot {
  border-top: 1px solid var(--l-line, #D7DEE9);
  padding: 10px;
  background: #fff;
}

.qr-chat-foot form {
  display: flex;
  gap: 8px;
}

.qr-chat-foot input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--l-line, #D7DEE9);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}

.qr-chat-foot button[type="submit"] {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--blue, #2E7DF6);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.qr-chat-tools {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.qr-chat-tools button {
  border: 0;
  background: transparent;
  color: var(--blue-ink, #1B5FCB);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.qr-chat-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--t-on-light-3, #57657C);
  line-height: 1.35;
}

/* Exit / lead modal */
.qr-chat-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--qr-chat-z) + 10);
  background: rgba(8, 13, 22, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.qr-chat-modal[hidden] { display: none !important; }

.qr-chat-modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: var(--sh-4);
}

.qr-chat-modal-card h2 {
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--t-on-light, #101828);
}

.qr-chat-modal-card > p {
  font-size: 14px;
  color: var(--t-on-light-2, #3D4A5E);
  margin: 0 0 14px;
  line-height: 1.45;
}

.qr-chat-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.qr-chat-channels label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--l-line, #D7DEE9);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.qr-chat-channels input { accent-color: var(--blue, #2E7DF6); }

.qr-chat-modal-card input[type="text"],
.qr-chat-modal-card input[type="email"],
.qr-chat-modal-card input[type="tel"] {
  width: 100%;
  border: 1px solid var(--l-line, #D7DEE9);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  margin-bottom: 10px;
}

.qr-chat-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--t-on-light-2, #3D4A5E);
  margin-bottom: 12px;
  line-height: 1.4;
}

.qr-chat-consent input { margin-top: 2px; }

.qr-chat-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.qr-chat-modal-actions button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.qr-chat-modal-actions .ghost {
  background: transparent;
  color: var(--t-on-light-2, #3D4A5E);
}

.qr-chat-modal-actions .primary {
  background: var(--blue, #2E7DF6);
  color: #fff;
}

body.has-cookie-bar .qr-chat-fab,
body.has-cookie-bar .qr-chat-panel {
  bottom: 88px;
}

@media (max-width: 520px) {
  .qr-chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 8px;
    height: min(70vh, 560px);
  }
  .qr-chat-fab { right: 12px; bottom: 12px; }
}
