/* =========================================================================
   Квиз «Списание долгов» — переработан в стиль «Госуслуги», как модальное окно.
   Логика и вопросы — те же, что на первом сайте; меняется только дизайн.
   ========================================================================= */

/* ------------------------------------------------------- overlay / modal */
.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.quiz-overlay[hidden] { display: none; }

.quiz-backdrop {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: rgba(11, 31, 51, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.quiz-overlay.open .quiz-backdrop { opacity: 1; }

.quiz-modal {
  position: relative;
  z-index: var(--z-modal);
  width: 480px;
  max-width: 100%;
  height: 600px;
  max-height: calc(100dvh - 40px);
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(11, 31, 51, 0.4);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.quiz-overlay.open .quiz-modal { opacity: 1; transform: none; }

.quiz-close {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 5;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}
.quiz-close:hover { background: rgba(255, 255, 255, 0.38); transform: rotate(90deg); }

/* ---------------------------------------------------------------- шапка */
.quiz-header {
  background: linear-gradient(135deg, #0d4cd3 0%, #2965ff 100%);
  padding: 20px 22px 16px;
  color: #fff;
  flex-shrink: 0;
}
.quiz-head-top { display: flex; align-items: center; gap: 13px; }
.avatar {
  width: 46px; height: 46px;
  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: 12px; height: 12px;
  background: #4ade80; border-radius: 50%;
  border: 2px solid #1c54d6;
  animation: pulse-dot 2s ease infinite;
}
.avatar.lottie-online .online-dot { display: none; }
.lottie-online-holder {
  position: absolute; bottom: -4px; right: -4px;
  width: 24px; height: 24px; 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 5px 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.92; }

.progress-bar {
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--r-pill);
  height: 5px;
  margin-top: 16px;
  overflow: hidden;
}
.progress-fill {
  background: #fff;
  height: 100%;
  border-radius: var(--r-pill);
  width: 20%;
  transition: width 0.45s var(--ease);
}
.progress-label { font-size: 11.5px; opacity: 0.78; margin-top: 7px; font-weight: 500; }

/* ---------------------------------------------------------------- чат */
.chat-area {
  flex: 1 1 0%;
  min-height: 56px;
  overflow-y: auto;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scroll-behavior: smooth;
  background: #f4f7fc;
}
.bot-row {
  display: flex; align-items: flex-end; gap: 9px;
  align-self: flex-start; max-width: 90%;
  animation: q-fadeUp 0.3s var(--ease) both;
}
.mini-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.mini-avatar svg { width: 16px; height: 16px; }

.bubble {
  max-width: 84%; min-width: 0;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  animation: q-fadeUp 0.3s var(--ease) both;
  word-break: break-word;
}
.bubble.bot {
  background: #fff;
  color: var(--ink);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 4px rgba(13, 38, 76, 0.06);
}
.bot-row .bubble.bot { align-self: unset; max-width: 100%; animation: none; }
.bubble.user {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 5px;
  align-self: flex-end;
  font-weight: 500;
}

.bubble.typing { background: #fff; align-self: flex-start; padding: 11px 15px; box-shadow: 0 1px 4px rgba(13,38,76,0.06); }
.bot-row.typing-row .bubble.typing { align-self: unset; animation: none; }
.lottie-typing { width: 48px; height: 20px; }
.dots { display: flex; gap: 5px; align-items: center; }
.dots span {
  width: 7px; height: 7px;
  background: #9db8ec; 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: none; }
}

/* ----------------------------------------------------- зона вариантов */
.input-zone { flex-shrink: 0; }
.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: 9px;
  padding-right: 2px;
}
.choices-area {
  padding: 10px 16px 18px;
  display: flex; flex-direction: column; gap: 9px;
  width: 100%;
}
.choice-btn {
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: 13px;
  padding: 14px 16px;
  font-size: 14.5px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  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, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-btn:hover { background: var(--blue-50); border-color: var(--blue); box-shadow: 0 4px 14px rgba(13,76,211,0.1); }
@media (hover: hover) { .choice-btn:hover { transform: translateX(2px); } }
.choice-btn:active { transform: scale(0.98); background: var(--blue-50); border-color: var(--blue); }

.choices-hint { font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 0 2px 3px; }

/* множественный выбор */
.choice-btn.multi { padding-right: 13px; }
.choice-btn .check-box {
  width: 23px; height: 23px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  display: grid; place-items: 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(--blue-50); border-color: var(--blue); }
.choice-btn.multi.selected .check-box { background: var(--blue); border-color: var(--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: 5px; }

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

/* телефон */
.phone-area { padding: 10px 16px 18px; display: flex; flex-direction: column; gap: 12px; width: 100%; }
.phone-prefix {
  background: var(--surface-2);
  border-right: 1.5px solid var(--border-strong);
  padding: 14px; font-size: 14px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 5px; white-space: nowrap; flex-shrink: 0;
}

.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: 2px; cursor: pointer; accent-color: var(--blue); }
.consent-label { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.consent-label a { color: var(--blue); text-decoration: none; font-weight: 500; }
.consent-label a:hover { text-decoration: underline; }

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

/* экран благодарности / тупик */
.thank-you {
  flex: 1 1 0%; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 15px; padding: 40px 26px; text-align: center;
  animation: q-fadeUp 0.4s var(--ease) both;
}
.ty-icon { width: 100px; height: 100px; }
.ty-title { font-size: 21px; font-weight: 700; color: var(--ink); }
.ty-text { font-size: 14.5px; color: var(--muted); line-height: 1.55; max-width: 320px; }
.ty-restart {
  margin-top: 6px; background: transparent;
  border: 1.5px solid var(--border-strong); color: var(--blue);
  border-radius: 12px; padding: 12px 20px;
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ty-restart:hover { background: var(--blue-50); border-color: var(--blue); }
.thank-you.dead-end .ty-icon { color: var(--red); }

/* футер квиза */
.legal-links {
  flex-shrink: 0; text-align: center;
  padding: 12px 16px 16px;
  background: #fff;
  font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.legal-links a { text-decoration: none; color: var(--muted); margin: 0 4px; transition: color 0.2s; }
.legal-links a:hover { color: var(--blue); text-decoration: underline; }
.legal-links span.sep { color: var(--border-strong); margin: 0 2px; }

/* ----------------------------------------------------- адаптив квиза */
@media (max-width: 520px) {
  .quiz-overlay { padding: 0; }
  .quiz-modal {
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  .quiz-header { padding: max(18px, env(safe-area-inset-top)) 18px 14px; }
  .chat-area { padding: 16px 14px 10px; gap: 10px; }
  .choices-area { padding: 10px 14px max(16px, env(safe-area-inset-bottom)); gap: 8px; }
  .phone-area { padding: 10px 14px max(16px, env(safe-area-inset-bottom)); }
  .legal-links { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-backdrop, .quiz-modal { transition: opacity 0.2s ease; transform: none; }
  .online-dot { animation: none; }
}
