/* ==========================================================================
   Lead + Survey (.bp-lead-survey)
   One section, two stages side-by-side inside a 200vw wrapper. CTA click
   adds `.is-stage-b` → wrapper slides `translateX(-100vw)` to reveal Stage B.
   Back button removes the class. Light theme throughout.
   ========================================================================== */

/* --- Section override — disable base flex centering so 200vw child can slide --- */
.bp-lead-survey {
    display: block;
    padding: 0;
    overflow: hidden;
    min-height: 100vh;
}

/* --- Stages wrapper — 2-col flex, horizontal slide ----------------------
   align-items: flex-start lets each stage keep its own height (Stage B is
   taller than A on mobile — 9 questions), so A's centered content won't
   drift if it inherited B's height. Height is JS-synced to the active
   stage (landing.js syncStagesHeight) so the section doesn't reserve empty
   scroll-space equal to the taller stage when the shorter one is showing. */
.bp-lead-survey__stages {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    width: 200vw;
    min-height: 100vh;
    transform: translateX(0);
    transition: transform 0.7s cubic-bezier(0.77, 0, 0.175, 1);
    will-change: transform;
}
.bp-lead-survey.is-stage-b .bp-lead-survey__stages {
    transform: translateX(-100vw);
}

/* --- Individual stage --------------------------------------------------- */
.bp-lead-survey__stage {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bp-lead-survey__inner {
    width: 100%;
    max-width: 1200px;
    padding: 96px 24px 120px;
    position: relative;
}
.bp-lead-survey__inner--b { max-width: 1040px; }

/* ============================================================
   Stage A — Lead form card
   ============================================================ */
.bp-lead-survey__card {
    background: #ffffff;
    border-radius: 32px;
    padding: 40px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.08);
    display: grid;
    grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
    gap: 40px;
    align-items: center;
}

.bp-lead-survey__poster {
    border-radius: 20px;
    overflow: hidden;
    background: #d9d9d9;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    width: 100%;
}
.bp-lead-survey__poster-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bp-lead-survey__poster-img--mobile { display: none; }

.bp-lead-survey__form-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bp-lead-survey__title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 800;
    line-height: 1.45;
    color: #171717;
}
.bp-lead-survey__brand {
    color: #E01C24;
    display: inline;
}

.bp-lead-survey__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.bp-lead-survey__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
}

/* --- Fields ---------------------------------------------------------- */
.bp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}
.bp-field--wide { grid-column: 1 / -1; max-width: calc(50% - 12px); }

.bp-field__label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #171717;
}
.bp-field__required {
    color: #E01C24;
    margin-left: 2px;
}

/* Scoped under `.bp-lead-survey` to out-specificity any theme/Gutenberg
   rule that targets bare `input[type="number"]` / `input[type="text"]` / `select`.
   Production theme was bumping border + padding on these controls. */
.bp-lead-survey .bp-field__input,
.bp-lead-survey .bp-field__select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #D4D4D4;
    border-radius: 6px;
    background: #ffffff;
    color: #171717;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
/* Strip the native number-input spinner — themes sometimes re-enable it. */
.bp-lead-survey .bp-field__input[type="number"] {
    -moz-appearance: textfield;
}
.bp-lead-survey .bp-field__input[type="number"]::-webkit-outer-spin-button,
.bp-lead-survey .bp-field__input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.bp-lead-survey .bp-field__select {
    padding-right: 36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1L6 6L11 1' stroke='%23171717' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}
.bp-lead-survey .bp-field__input::placeholder {
    color: #A3A3A3;
}
.bp-lead-survey .bp-field__select option[disabled] {
    color: #A3A3A3;
}
.bp-lead-survey .bp-field__input:focus,
.bp-lead-survey .bp-field__select:focus {
    outline: none;
    border-color: #E01C24;
    box-shadow: 0 0 0 3px rgba(224, 28, 36, 0.12);
}
.bp-lead-survey .bp-field.is-error .bp-field__input,
.bp-lead-survey .bp-field.is-error .bp-field__select {
    border-color: #E01C24;
}
.bp-lead-survey .bp-field__other {
    margin-top: 8px;
    padding: 10px 14px;
    border: 1px solid #D4D4D4;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #ffffff;
    color: #171717;
}

/* --- Combobox (type-to-search dropdown, used by province field) --------- */
.bp-combobox {
    position: relative;
}
.bp-lead-survey .bp-combobox__input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid #D4D4D4;
    border-radius: 6px;
    background: #ffffff;
    color: #171717;
    font-family: inherit;
    /* 16px (not 0.95rem) at all breakpoints: iOS Safari auto-zooms any
       input with computed font-size < 16px on focus. The mobile-only
       override wasn't winning for this selector in practice, so keep
       16px baked into the base rule. Visual delta on desktop is ~0.8px
       — imperceptible. */
    font-size: 16px;
    line-height: 1.5;
    cursor: text;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1L6 6L11 1' stroke='%23171717' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bp-lead-survey .bp-combobox__input::placeholder { color: #A3A3A3; }
.bp-lead-survey .bp-combobox__input:focus {
    outline: none;
    border-color: #E01C24;
    box-shadow: 0 0 0 3px rgba(224, 28, 36, 0.12);
}
.bp-lead-survey .bp-field.is-error .bp-combobox__input {
    border-color: #E01C24;
}
.bp-combobox__list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid #D4D4D4;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.bp-combobox__list[hidden] { display: none; }
.bp-combobox__option {
    padding: 8px 14px;
    font-size: 0.95rem;
    color: #171717;
    cursor: pointer;
    transition: background 0.15s;
}
.bp-combobox__option[hidden] { display: none; }
.bp-combobox__option:hover,
.bp-combobox__option.is-active {
    background: #F5F5F5;
}
.bp-combobox__empty {
    padding: 12px 14px;
    font-size: 0.9rem;
    color: #A3A3A3;
    text-align: center;
    list-style: none;
}
.bp-combobox__empty[hidden] { display: none; }

/* --- "ถัดไป >" next button ------------------------------------------- */
.bp-lead-survey__actions--a {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 8px;
}
.bp-lead-survey__next {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 999px;
    background: #171717;
    color: #ffffff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.bp-lead-survey__next:hover,
.bp-lead-survey__next:focus-visible {
    background: #000000;
    outline: none;
    transform: translateY(-1px);
}
.bp-lead-survey__next:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
.bp-lead-survey__next-icon {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* --- Stage A social icons — positioned at viewport bottom-left (outside
       the form-card inner, pinned to the 100vw stage edge). --- */
.bp-lead-survey__stage--a > .bp-social-icons {
    position: absolute;
    bottom: 40px;
    left: 40px;
    z-index: 2;
}

/* ============================================================
   Stage B — Survey
   ============================================================ */
.bp-lead-survey__title--b {
    text-align: center;
    font-size: 1.5rem;
    margin: 0 auto;
    max-width: 900px;
}

.bp-lead-survey__progress {
    margin: 20px auto 32px;
    max-width: 900px;
    height: 6px;
    background: #D9D9D9;
    overflow: hidden;
    position: relative;
}
.bp-lead-survey__progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--bp-progress, 50%);
    background: #E01C24;
    transition: width 0.35s ease;
}

.bp-lead-survey__survey-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bp-survey-question {
    background: #ffffff;
    border: 1px solid #E5E5E5;
    border-radius: 14px;
    padding: 20px 24px;
    transition: border-color 0.2s;
}
.bp-survey-question.is-error {
    border-color: #E01C24;
}
.bp-survey-question__text {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.55;
    color: #171717;
}
.bp-survey-question__num {
    color: #171717;
    margin-right: 4px;
}

/* --- Likert (horizontal: labels above, dots below) ------------------- */
.bp-likert-scale {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}
.bp-likert-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #171717;
    min-width: 72px;
}
.bp-likert-option__label {
    white-space: nowrap;
}
.bp-likert-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.bp-likert-option__dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #A3A3A3;
    background: #ffffff;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}
.bp-likert-option input[type="radio"]:checked + .bp-likert-option__dot {
    border-color: #E01C24;
}
.bp-likert-option input[type="radio"]:checked + .bp-likert-option__dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #E01C24;
}
.bp-likert-option:hover .bp-likert-option__dot {
    border-color: #E01C24;
}

/* --- Radio group (vertical, left-aligned) ---------------------------- */
.bp-radio-group,
.bp-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bp-radio-option,
.bp-checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #171717;
    padding: 4px 0;
}
.bp-radio-option input[type="radio"],
.bp-checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.bp-radio-option__dot {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #A3A3A3;
    background: #ffffff;
    position: relative;
    margin-top: 3px;
    transition: border-color 0.2s, background 0.2s;
}
.bp-radio-option input[type="radio"]:checked + .bp-radio-option__dot {
    border-color: #E01C24;
}
.bp-radio-option input[type="radio"]:checked + .bp-radio-option__dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #E01C24;
}
.bp-radio-option:hover .bp-radio-option__dot {
    border-color: #E01C24;
}

.bp-checkbox-option__box {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid #A3A3A3;
    background: #ffffff;
    position: relative;
    margin-top: 3px;
    transition: border-color 0.2s, background 0.2s;
}
.bp-checkbox-option input[type="checkbox"]:checked + .bp-checkbox-option__box {
    background: #E01C24;
    border-color: #E01C24;
}
.bp-checkbox-option input[type="checkbox"]:checked + .bp-checkbox-option__box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
}
.bp-checkbox-option:hover .bp-checkbox-option__box {
    border-color: #E01C24;
}

.bp-survey-question__other-input {
    display: block;
    margin-top: 8px;
    margin-left: 30px;
    padding: 8px 12px;
    border: 1px solid #D4D4D4;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    color: #171717;
    width: 100%;
    max-width: 400px;
}

/* --- Stage B actions (back + submit) ---------------------------------- */
.bp-lead-survey__actions--b {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding-bottom: 8px;
}
.bp-lead-survey__back,
.bp-lead-survey__submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.bp-lead-survey__back {
    background: #ffffff;
    color: #171717;
    border: 1px solid #C8C8C8;
}
.bp-lead-survey__back:hover,
.bp-lead-survey__back:focus-visible {
    background: #F5F5F5;
    color: #000000;
    outline: none;
    transform: translateY(-1px);
}
.bp-lead-survey__back-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    /* chevron-left.svg ships with stroke="white" (reused by section-8 .bp-btn-back
       on a dark glass bg). Flip to solid black for use on this white button. */
    filter: brightness(0);
}

.bp-lead-survey__submit {
    background: #171717;
    color: #ffffff;
    border: none;
}
.bp-lead-survey__submit:hover:not(:disabled),
.bp-lead-survey__submit:focus-visible:not(:disabled) {
    background: #000000;
    outline: none;
    transform: translateY(-1px);
}
.bp-lead-survey__submit:disabled {
    background: #D4D4D4;
    color: #A3A3A3;
    cursor: not-allowed;
    transform: none;
}
.bp-lead-survey__submit-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: filter 0.2s;
}
.bp-lead-survey__submit:disabled .bp-lead-survey__submit-icon {
    /* SVG has stroke="white" — swap to grey #A3A3A3 when disabled. */
    filter: brightness(0) saturate(100%) invert(69%) sepia(0%) saturate(0%) hue-rotate(139deg) brightness(94%) contrast(89%);
}

/* ============================================================
   Closed state — shown when Admin toggles "ปิดการกรอก" off
   ============================================================ */
.bp-lead-survey__inner--closed {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: none;
    padding: 96px 24px 120px;
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Pin social icons to bottom-left of the viewport (same pattern as Stage A).
   Keeping them in normal flow makes them a flex sibling and pushes the card
   off-center. */
.bp-lead-survey__inner--closed > .bp-social-icons {
    position: absolute;
    bottom: 40px;
    left: 40px;
    z-index: 2;
}
.bp-lead-survey__closed-card {
    max-width: 720px;
    width: 100%;
}
.bp-lead-survey__closed-card {
    background: #ffffff;
    border-radius: 32px;
    padding: 56px 48px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%;
}
.bp-lead-survey__closed-icon {
    display: block;
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    padding: 14px;
    border-radius: 999px;
    background: rgba(224, 28, 36, 0.1);
    filter: none;
}
.bp-lead-survey__closed-title {
    margin: 0 0 16px;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.4;
    color: #171717;
}
.bp-lead-survey__closed-message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: #525252;
}
/* CTA pill on the already-submitted card. Kept inside the closed-card
   block since it visually only appears in the `is-submitted` state. */
.bp-lead-survey__closed-cta {
    display: inline-block;
    margin-top: 28px;
    padding: 12px 36px;
    background: #E01C24;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 999px;
    transition: background 0.2s ease;
}
.bp-lead-survey__closed-cta:hover,
.bp-lead-survey__closed-cta:focus {
    background: #b01820;
    color: #ffffff;
}

/* ==========================================================================
   Tablet (≤1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .bp-lead-survey__card {
        grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
        gap: 28px;
        padding: 32px;
    }
    .bp-lead-survey__title { font-size: 1.25rem; }
}

/* ==========================================================================
   Mobile (≤768px) — card flips to single column, poster switches to 16:9
   ========================================================================== */
@media (max-width: 768px) {
    .bp-lead-survey__inner {
        padding: 72px 16px 96px;
    }

    .bp-lead-survey__card {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
        border-radius: 20px;
    }
    .bp-lead-survey__poster {
        aspect-ratio: 16 / 9;
        border-radius: 14px;
    }
    .bp-lead-survey__poster-img--desktop { display: none; }
    .bp-lead-survey__poster-img--mobile  { display: block; }

    .bp-lead-survey__title {
        font-size: 1.125rem;
    }

    .bp-lead-survey__grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .bp-field--wide { max-width: 100%; }

    /* iOS Safari auto-zooms any focused input/select whose font-size < 16px.
       The desktop styles use 0.95rem (~15.2px) which trips the zoom on phones.
       Bump to 16px strictly on mobile so the viewport stays put on focus.
       (`.bp-combobox__input` is 16px in its base rule — not needed here.) */
    .bp-lead-survey .bp-field__input,
    .bp-lead-survey .bp-field__select,
    .bp-lead-survey .bp-field__other {
        font-size: 16px;
    }

    .bp-lead-survey__actions--a {
        justify-content: flex-end;
    }

    /* Hide social icons on mobile (lead form only) — design omits them there. */
    .bp-lead-survey__stage--a > .bp-social-icons {
        display: none;
    }

    /* --- Stage B mobile --- */
    .bp-lead-survey__title--b {
        font-size: 1.125rem;
        text-align: center;
    }
    .bp-lead-survey__progress {
        margin: 16px 0 20px;
    }
    .bp-survey-question {
        padding: 16px 18px;
        border-radius: 12px;
    }
    .bp-survey-question__text {
        font-size: 0.95rem;
    }
    .bp-likert-scale {
        gap: 10px;
        justify-content: space-between;
    }
    .bp-likert-option {
        min-width: 48px;
        font-size: 0.75rem;
    }
    .bp-likert-option__label {
        text-align: center;
        white-space: normal;
        line-height: 1.3;
    }
    .bp-lead-survey__actions--b {
        justify-content: space-between;
        gap: 8px;
    }
    .bp-lead-survey__back,
    .bp-lead-survey__submit {
        padding: 9px 18px;
        font-size: 0.9rem;
    }

    /* --- Closed state --- */
    .bp-lead-survey__inner--closed {
        padding: 72px 16px 96px;
    }
    .bp-lead-survey__inner--closed > .bp-social-icons {
        display: none;
    }
    .bp-lead-survey__closed-card {
        padding: 36px 24px;
        border-radius: 20px;
    }
    .bp-lead-survey__closed-title { font-size: 1.2rem; }
    .bp-lead-survey__closed-message { font-size: 0.95rem; }
    .bp-lead-survey__closed-cta {
        margin-top: 24px;
        padding: 10px 28px;
        font-size: 0.95rem;
    }
}
