/* ==================================================================
   КВИЗ-ОВЕРЛЕЙ — общий для всех трёх лендингов.
   Тема настраивается переменными в :root каждого сайта:
     --q-blue, --q-blue-deep, --q-blue-soft, --q-blue-line,
     --q-ink, --q-grad-btn, --q-grad-header, --q-chat-bg, --q-radius
   ================================================================== */
.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 23, 48, 0.52);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.quiz-overlay.open { opacity: 1; }
.quiz-overlay[hidden] { display: none; }

body.quiz-open { overflow: hidden; }

/* ---- Карточка квиза ---- */
.quiz-wrapper {
  width: 480px;
  max-width: 100%;
  height: 640px;
  max-height: calc(100dvh - 40px);
  background: #fff;
  border-radius: var(--q-radius, 24px);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(10, 18, 40, 0.35);
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: var(--q-font, Manrope, "Segoe UI", system-ui, sans-serif);
}
.quiz-overlay.open .quiz-wrapper { transform: none; }

/* ---- Шапка квиза ---- */
.quiz-header {
  background: var(--q-grad-header);
  padding: 16px 18px 14px;
  color: #fff;
  flex-shrink: 0;
}
.header-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.avatar-icon { display: flex; line-height: 1; }
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid var(--q-blue-deep, #1D46CE);
  animation: pulse-dot 2s ease infinite;
}
.avatar.lottie-online .online-dot { display: none; }
.lottie-online-holder {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  pointer-events: none;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
.header-info { min-width: 0; }
.header-name { font-size: 16px; font-weight: 700; }
.header-status { font-size: 13px; opacity: 0.9; }

.quiz-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.quiz-close:hover { background: rgba(255, 255, 255, 0.28); }
.quiz-close:active { transform: scale(0.92); }

.progress-bar {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 99px;
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  background: #fff;
  height: 100%;
  border-radius: 99px;
  width: 20%;
  transition: width 0.4s;
}
.progress-label { font-size: 11px; opacity: 0.7; margin-top: 6px; }

/* ---- Чат ---- */
.chat-area {
  flex: 1 1 0%;
  min-height: 56px;
  overflow-y: auto;
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background-color: var(--q-chat-bg, #F5F8FE);
}

.bot-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
  animation: q-fadeUp 0.3s ease both;
}
.mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--q-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.mini-avatar svg { width: 16px; height: 16px; }

.bubble {
  max-width: 82%;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  animation: q-fadeUp 0.3s ease both;
  word-break: break-word;
}
.bubble.bot {
  background: #fff;
  color: var(--q-ink, #0F1B33);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 27, 51, 0.05);
}
.bot-row .bubble.bot { align-self: unset; max-width: 100%; animation: none; }
.bubble.user {
  background: var(--q-grad-btn);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
}

/* индикатор «печатает» */
.bubble.typing { background: #fff; align-self: flex-start; padding: 10px 14px; }
.bot-row.typing-row .bubble.typing { align-self: unset; animation: none; }
.lottie-typing { width: 46px; height: 20px; }
.dots { display: flex; gap: 5px; align-items: center; }
.dots span {
  width: 7px; height: 7px;
  background: var(--q-blue);
  opacity: 0.55;
  border-radius: 50%;
  animation: q-blink 1.2s ease infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes q-blink {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@keyframes q-fadeUp {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---- Зона вариантов ---- */
.input-zone { flex-shrink: 0; background: #fff; }
.input-zone.grow { flex: 1 1 0%; min-height: 0; display: flex; flex-direction: column; }
.input-zone.panel {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.input-zone.panel .choices-area {
  flex: 1 1 auto;
  min-height: 0;
}
.choices-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.choices-area {
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.choice-btn {
  background: #fff;
  border: 1.5px solid var(--q-blue-line);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--q-ink, #0F1B33);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-btn:hover { background: var(--q-blue-soft); border-color: var(--q-blue); }
@media (hover: hover) { .choice-btn:hover { transform: translateX(2px); } }
.choice-btn:active { transform: scale(0.97); background: var(--q-blue-soft); border-color: var(--q-blue); }
.choice-badge {
  background: var(--q-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.choices-hint {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  padding: 0 2px 2px;
}

/* множественный выбор */
.choice-btn.multi { padding-right: 12px; }
.choice-btn .check-box {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 1.5px solid var(--q-blue-line);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.choice-btn .check-box svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.choice-btn.multi.selected {
  background: var(--q-blue-soft);
  border-color: var(--q-blue);
}
.choice-btn.multi.selected .check-box {
  background: var(--q-blue);
  border-color: var(--q-blue);
}
.choice-btn.multi.selected .check-box svg { opacity: 1; transform: scale(1); }
.choice-btn.multi:active { transform: scale(0.985); }
.submit-btn.multi-cta { margin-top: 4px; }

/* текстовое поле */
.text-row {
  display: flex;
  border: 1.5px solid var(--q-blue-line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  width: 100%;
}
.text-row:focus-within { border-color: var(--q-blue); }
.text-input {
  flex: 1 1 0%;
  border: none;
  outline: none;
  padding: 13px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  color: var(--q-ink, #0F1B33);
  background: transparent;
  min-width: 0;
}
.text-input::placeholder { color: #94a3b8; font-weight: 400; }
@media (max-width: 520px) { .text-input { font-size: 16px; } }

/* ---- Контакт ---- */
.phone-area {
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 100%;
}
.phone-row {
  display: flex;
  border: 1.5px solid var(--q-blue-line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  width: 100%;
}
.phone-row:focus-within { border-color: var(--q-blue); }
.phone-prefix {
  background: var(--q-blue-soft);
  border-right: 1.5px solid var(--q-blue-line);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  color: var(--q-ink, #0F1B33);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.phone-input {
  flex: 1 1 0%;
  border: none;
  outline: none;
  padding: 13px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  color: var(--q-ink, #0F1B33);
  background: transparent;
  min-width: 0;
}
.phone-input::placeholder { color: #94a3b8; font-weight: 400; }

.consent-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.consent-check { width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px; cursor: pointer; accent-color: var(--q-blue); }
.consent-label { font-size: 12.5px; color: #64748b; line-height: 1.5; }
.consent-label a { color: var(--q-blue); text-decoration: none; font-weight: 500; }
.consent-label a:hover { text-decoration: underline; }

.submit-btn {
  background: var(--q-grad-btn);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.submit-btn:hover { filter: brightness(1.06); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

/* ---- Экран благодарности ---- */
.thank-you {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
  animation: q-fadeUp 0.4s ease both;
}
.ty-icon { width: 96px; height: 96px; }
.ty-title { font-size: 20px; font-weight: 700; color: var(--q-ink, #0F1B33); }
.ty-text { font-size: 14px; color: #64748b; line-height: 1.55; max-width: 320px; }

/* ---- Футер квиза ---- */
.quiz-legal {
  flex-shrink: 0;
  text-align: center;
  padding: 9px 14px 12px;
  background: #fff;
  font-size: 10px;
  color: #64748b;
  border-top: 1px solid #EDF1F8;
  letter-spacing: 0.2px;
  line-height: 1.5;
}
.quiz-legal a { text-decoration: none; color: #94a3b8; white-space: nowrap; }
.quiz-legal a:hover { color: var(--q-blue); text-decoration: underline; }
.quiz-legal .sep { color: #cbd5e0; margin: 0 3px; }
.quiz-legal .legal-company { color: #334155; font-weight: 500; }
.quiz-legal .legal-docs { margin-top: 4px; }

/* ---- Мобильный квиз: во весь экран ---- */
@media (max-width: 640px) {
  .quiz-overlay { padding: 0; align-items: flex-start; }
  .quiz-wrapper {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .quiz-header { padding: max(14px, env(safe-area-inset-top)) 12px 12px; }
  .chat-area { padding: 14px 12px 8px; gap: 9px; }
  .bubble { font-size: 13.5px; padding: 10px 13px; max-width: 88%; }
  .choices-area { padding: 8px 12px max(16px, env(safe-area-inset-bottom)); gap: 7px; }
  .choice-btn { padding: 14px 16px; }
  .phone-area { padding: 8px 12px max(16px, env(safe-area-inset-bottom)); }
  .phone-input { font-size: 16px; }
  .consent-check { width: 20px; height: 20px; }
  .submit-btn { padding: 16px 20px; }
  .quiz-legal { padding: 8px 12px 10px; font-size: 9.5px; }
}
