/* =============================================
   Quiz Module — Frontend Styles
   OpenCart 3.x
   Подключить: catalog/view/theme/default/stylesheet/quiz.css
   ============================================= */

.quiz-widget {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 28px;
  margin: 24px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  font-family: inherit;
}

/* ── Шапка ─────────────────────────────────── */
.quiz-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  color: #222;
}

.quiz-description {
  color: #666;
  margin: 0 0 16px;
}

/* ── Прогресс-бар ──────────────────────────── */
.quiz-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-progress-bar {
  flex: 1;
  height: 6px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e44d26, #f1652a);
  border-radius: 4px;
  transition: width .4s ease;
}

.quiz-progress-text {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
}

/* ── Вопрос ────────────────────────────────── */
.quiz-question {
  animation: quizFadeIn .3s ease;
}

.quiz-question--hidden {
  display: none !important;
}

@keyframes quizFadeIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0);    }
}

.quiz-question-text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}

/* ── Ответы ────────────────────────────────── */
.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-answer-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  font-weight: normal;
  margin: 0;
}

.quiz-answer-label:hover {
  border-color: #e44d26;
  background: #fff8f6;
}

.quiz-answer-input {
  accent-color: #e44d26;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.quiz-answer-input:checked + .quiz-answer-text {
  font-weight: 600;
}

.quiz-answer-label:has(.quiz-answer-input:checked) {
  border-color: #e44d26;
  background: #fff3f0;
}

/* Встряска при ошибке валидации */
@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-6px); }
  75%       { transform: translateX(6px); }
}

.quiz-answers--shake {
  animation: quizShake .35s ease;
}

/* ── Навигация ─────────────────────────────── */
.quiz-nav {
  display: flex;
  gap: 10px;
}

/* ── Результаты ────────────────────────────── */
.quiz-result {
  animation: quizFadeIn .4s ease;
}

.quiz-result-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #eee;
  padding-bottom: 16px;
}

.quiz-result-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #222;
}

.quiz-result-description {
  color: #666;
}

.quiz-product-card {
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
  transition: box-shadow .2s;
}

.quiz-product-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

.quiz-product-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.quiz-product-info {
  padding: 12px;
}

.quiz-product-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: #333;
  margin-bottom: 4px;
  text-decoration: none;
  line-height: 1.4;
  max-height: 2.8em;
  overflow: hidden;
}

.quiz-product-name:hover { color: #e44d26; }

.quiz-product-rating {
  color: #f0a500;
  font-size: 11px;
  margin-bottom: 4px;
}

.quiz-product-price {
  font-weight: 700;
  font-size: 15px;
  color: #e44d26;
  margin-bottom: 8px;
}

.quiz-result-footer {
  margin-top: 24px;
  text-align: center;
  border-top: 1px solid #eee;
  padding-top: 16px;
}

/* ── Лоадер ────────────────────────────────── */
.quiz-loader {
  text-align: center;
  padding: 40px 0;
  color: #999;
}

.quiz-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #eee;
  border-top-color: #e44d26;
  border-radius: 50%;
  animation: quizSpin .8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes quizSpin {
  to { transform: rotate(360deg); }
}

/* ── Адаптив ────────────────────────────────── */
@media (max-width: 480px) {
  .quiz-widget     { padding: 16px; }
  .quiz-title      { font-size: 18px; }
  .quiz-question-text { font-size: 15px; }
  .quiz-product-card img { height: 130px; }
}

/* ══════════════════════════════════════════════
   Quiz Popup / Modal
   ══════════════════════════════════════════════ */

/* Оверлей */
.quiz-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 9998;
  backdrop-filter: blur(2px);
  animation: quizOverlayIn .25s ease;
}

.quiz-overlay.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes quizOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Само окно */
.quiz-modal {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 92%;
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 0;
  animation: quizModalIn .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
}

@keyframes quizModalIn {
  from { opacity: 0; transform: scale(.92) translateY(24px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);     }
}

/* Кнопка закрытия */
.quiz-modal__close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  color: #555;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  z-index: 1;
  transition: background .2s, color .2s;
}

.quiz-modal__close:hover {
  background: #e44d26;
  color: #fff;
}

/* Содержимое — убираем внешние отступы виджета внутри попапа */
.quiz-modal .quiz-widget {
  border: none;
  box-shadow: none;
  margin: 0;
  border-radius: 0 0 12px 12px;
}

/* Лоадер внутри попапа пока грузится HTML */
.quiz-modal__loading {
  text-align: center;
  padding: 48px 24px;
  color: #aaa;
}

.quiz-modal__loading .quiz-spinner {
  margin: 0 auto 16px;
}

/* Адаптив попапа */
@media (max-width: 600px) {
  .quiz-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    animation: quizModalInMobile .3s ease;
  }

  @keyframes quizModalInMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0);    }
  }

  .quiz-overlay.is-open {
    align-items: flex-end;
  }
}
