/**
 * Nazap Quiz – Frontend
 * Matches nazap.co.il quiz layout exactly:
 * - Centered white card
 * - Title + subtitle at top
 * - Thin purple progress bar full width
 * - "Step X of Y" right-aligned label
 * - Multiple questions per step, each with 4-column answer grid
 * - Radio circle top-left of each answer box
 * - Dark teal "← Next" pill button bottom right
 */

/* ── Reset / base ─────────────────────────────────────────────────────────── */
.nazap-quiz-wrap *,
.nazap-quiz-wrap *::before,
.nazap-quiz-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }

.nazap-quiz-wrap {
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
    color: #1e1b2e;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Elementor compat */
.elementor-widget-shortcode .nazap-quiz-wrap,
.elementor .nazap-quiz-wrap { max-width: 100%; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.nq-card {
    background: #fff;
    border: 1px solid #e8e4ef;
    border-radius: 4px;
    padding: 36px 48px 40px;
    position: relative;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.nq-header { margin-bottom: 0; }

.nq-title {
    text-align: right;
    font-size: 22px;
    font-weight: 700;
    color: #1e1b2e;
    margin-bottom: 4px;
    line-height: 1.3;
}

.nq-subtitle {
    text-align: right;
    font-size: 13px;
    color: #888;
    margin-bottom: 16px;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.nq-progress-bar-wrap {
    width: 100%;
    margin-bottom: 6px;
}
.nq-progress-bar {
    width: 100%;
    height: 4px;
    background: #e8e4ef;
    border-radius: 2px;
    overflow: hidden;
}
.nq-progress-fill {
    height: 100%;
    background: #5c4b7a;
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

.nq-step-label {
    text-align: right;
    font-size: 12px;
    color: #888;
    margin-bottom: 28px;
}

/* ── Steps container ─────────────────────────────────────────────────────── */
.nq-step {
    display: none;
}
.nq-step.active {
    display: block;
    animation: nqFadeIn 0.3s ease;
}
@keyframes nqFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Single question block ────────────────────────────────────────────────── */
.nq-question-block {
    margin-bottom: 28px;
}

.nq-question-text {
    text-align: right;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 12px;
    line-height: 1.5;
}

/* ── Answer grid (columns set dynamically by JS; 4 is the default fallback) ── */
.nq-answers-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    list-style: none;
}

/* ── Answer box ───────────────────────────────────────────────────────────── */
.nq-answer-box {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 10px 10px 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 70px;
    user-select: none;
}
.nq-answer-box:hover {
    border-color: #5c4b7a;
    background: #faf8fd;
}
.nq-answer-box.selected {
    border-color: #5c4b7a;
    background: #faf8fd;
}

/* Radio circle – top left of box */
.nq-radio {
    width: 16px;
    height: 16px;
    border: 1px solid #bbb;
    border-radius: 50%;
    margin-bottom: 10px;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s;
}
.nq-answer-box:hover  .nq-radio,
.nq-answer-box.selected .nq-radio {
    border-color: #5c4b7a;
}
.nq-answer-box.selected .nq-radio::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #5c4b7a;
}

/* Checkbox variant */
.nq-answer-box[data-type="multiple_choice"] .nq-radio {
    border-radius: 3px;
}
.nq-answer-box[data-type="multiple_choice"].selected .nq-radio::after {
    content: '✓';
    width: auto; height: auto;
    background: transparent;
    color: #5c4b7a;
    font-size: 10px;
    font-weight: 700;
    border-radius: 0;
}

/* Answer label */
.nq-answer-label {
    font-size: 12px;
    color: #444;
    line-height: 1.3;
    text-align: left;
}

/* Text inputs */
.nq-text-input,
.nq-textarea-input {
    width: 100%;
    font-size: 14px;
    font-family: inherit;
    color: #1e1b2e;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.15s;
    direction: rtl;
    resize: none;
}
.nq-text-input:focus,
.nq-textarea-input:focus {
    border-color: #5c4b7a;
    background: #fff;
}
.nq-textarea-input { min-height: 100px; }

/* Validation */
.nq-question-block.has-error .nq-answer-box,
.nq-question-block.has-error .nq-text-input,
.nq-question-block.has-error .nq-textarea-input { border-color: #e74c3c; }
.nq-field-error {
    display: none;
    color: #e74c3c;
    font-size: 12px;
    margin-top: 6px;
    text-align: right;
}
.nq-question-block.has-error .nq-field-error { display: block; }

/* ── Navigation ───────────────────────────────────────────────────────────── */
.nq-nav {
    display: flex;
    justify-content: space-between;   /* Next always on physical left, Prev always on physical right */
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    position: relative;
    z-index: 999;
}
/*
 * nq-btn-hidden uses visibility:hidden (not display:none) so the Prev button
 * keeps its space on the right on step 1 – NEXT stays pinned to the left.
 */

/* Hidden (visibility) – preserves space so RTL layout stays stable on step 0 */
.nq-btn-hidden {
    visibility: hidden;
    pointer-events: none;
}

.nq-btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 28px;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    outline: none;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.nq-btn-next,
.nq-btn-submit {
    background: #4a5e5a;
    color: #fff;
}
.nq-btn-next:hover,
.nq-btn-submit:hover { background: #3a4e4a; }
.nq-btn-next:active,
.nq-btn-submit:active { transform: scale(0.97); }

.nq-btn-prev {
    background: transparent;
    color: #4a5e5a;
    border: 1px solid #ccc;
}
.nq-btn-prev:hover { border-color: #4a5e5a; background: #f0f4f3; }

.nq-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Loading dots */
.nq-dots { display: inline-flex; gap: 3px; align-items: center; }
.nq-dots span {
    width: 5px; height: 5px;
    background: rgba(255,255,255,.8);
    border-radius: 50%;
    animation: nqDot 0.7s ease infinite;
}
.nq-dots span:nth-child(2) { animation-delay: .15s; }
.nq-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes nqDot {
    0%,80%,100%{transform:scale(.7);opacity:.5}
    40%{transform:scale(1.1);opacity:1}
}

/* ── Thank you ────────────────────────────────────────────────────────────── */
.nq-thankyou {
    text-align: center;
    padding: 60px 20px;
    animation: nqFadeIn 0.5s ease;
}
.nq-ty-icon {
    width: 70px; height: 70px;
    background: #5c4b7a;
    color: #fff;
    font-size: 32px;
    line-height: 70px;
    border-radius: 50%;
    margin: 0 auto 20px;
}
.nq-thankyou h3 { font-size: 22px; font-weight: 700; color: #1e1b2e; margin-bottom: 8px; }
.nq-thankyou p  { font-size: 15px; color: #777; }

/* ── Error msg ────────────────────────────────────────────────────────────── */
.nq-error {
    margin-top: 12px;
    padding: 10px 16px;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #c0392b;
    font-size: 13px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .nq-card { padding: 24px 18px 28px; }
    .nq-answers-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .nq-title { font-size: 18px; }
}
@media (max-width: 380px) {
    .nq-answers-grid { grid-template-columns: 1fr 1fr !important; }
}

/* RTL support — Previous on right, Next on left (no row-reverse) */
[dir="rtl"] .nq-title,
[dir="rtl"] .nq-subtitle,
[dir="rtl"] .nq-question-text,
[dir="rtl"] .nq-step-label { text-align: right; }
[dir="rtl"] .nq-answer-label { text-align: right; }

/* ── Contact / Results step ─────────────────────────────────────────────── */
.nq-contact-inner {
    max-width: 460px;
    margin: 0 auto;
    padding: 12px 0 8px;
    text-align: center;
}
.nq-contact-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e1b2e;
    margin-bottom: 6px;
}
.nq-contact-sub {
    font-size: 14px;
    color: #777;
    margin-bottom: 28px;
    line-height: 1.5;
}
.nq-contact-field {
    text-align: right;
    margin-bottom: 18px;
}
.nq-contact-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
    text-align: right;
}
.nq-req { color: #e74c3c; }
.nq-contact-field .nq-text-input {
    width: 100%;
}
.nq-contact-field.has-error .nq-text-input {
    border-color: #e74c3c;
}
.nq-contact-field.has-error .nq-field-error {
    display: block;
}

/* Submit button — full purple on contact step */
.nq-btn-submit {
    background: #5c4b7a;
    color: #fff;
    padding: 12px 36px;
    font-size: 15px;
}
.nq-btn-submit:hover { background: #4a3d63; }

/* Thank-you enhancements */
.nq-ty-msg {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin-top: 6px;
}
