/* =========================================================
   Espace Particulier – Demande de devis (step.php)
   File: /particulier2/css/step-client.css
   ========================================================= */

/* ---------- Visitors (no sidebar) ---------- */
body.kp-step-guest {
    background: var(--kp-bg);
    color: var(--kp-text);
}

.kp-step-guest-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

/* ---------- Title ---------- */
.kp-step-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding: 1.4rem 1.75rem;
    border-radius: 14px;
    background: var(--kp-primary);
    color: #ffffff;
}

.kp-step-hero-img {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 12px;
    background: #ffffff;
    object-fit: cover;
}

.kp-step-hero-text {
    flex: 1;
    min-width: 0;
}

.kp-step-hero .kp-np-kicker {
    display: inline-block;
    margin-bottom: 0.3rem;
    padding: 0.15rem 0.65rem;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.kp-step-hero h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
}

.kp-step-hero p {
    margin: 0.25rem 0 0;
    opacity: 0.92;
}

.kp-step-change {
    flex-shrink: 0;
    padding: 0.55rem 1rem;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    border-radius: 100px;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.kp-step-change:hover {
    background: #ffffff;
    color: var(--kp-primary-dark);
    text-decoration: none;
}

/* ---------- Cards ---------- */
.kp-step-card {
    padding: 1.75rem 2rem 2rem;
}

#haveAllQuestions {
    max-width: 900px;
}

[hidden] {
    display: none !important;
}

/* ---------- Progress ---------- */
.kp-step-progress {
    margin-bottom: 1.5rem;
}

.kp-step-progress-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--kp-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

#stepCounter {
    color: var(--kp-primary-dark);
    text-transform: capitalize;
}

.kp-step-bar {
    height: 8px;
    border-radius: 100px;
    background: #e3eadf;
    overflow: hidden;
}

.kp-step-bar span {
    display: block;
    height: 100%;
    border-radius: 100px;
    background: var(--kp-primary);
    transition: width 0.35s ease;
}

/* ---------- Question ---------- */
.step {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.step.active {
    animation: kp-step-in 0.25s ease;
}

@keyframes kp-step-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .step.active { animation: none; }
    .kp-step-bar span { transition: none; }
}

.step legend {
    float: none;
    width: 100%;
    margin: 0;
    padding: 0;
}

.step legend label {
    display: block;
    margin: 0;
}

.step legend h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--kp-text);
}

.kp-step-help {
    margin: 0.35rem 0 0;
    color: var(--kp-muted);
    font-size: 0.88rem;
}

.step .ans {
    margin-top: 1.25rem;
}

/* Answer tiles (radio / checkbox) */
.kp-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
}

.kp-options .option {
    position: relative;
    margin: 0;
}

.kp-options .option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.kp-options .option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
    margin: 0;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--kp-border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--kp-text);
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.kp-options .option-label:hover {
    border-color: #a9c49b;
    background: #f7fbf4;
}

.kp-options .option-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Check mark */
.kp-options .option-label::after {
    content: "";
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-left: auto;
    border: 1.5px solid #c5cec0;
    border-radius: 50%;
    background: #ffffff no-repeat center / 14px;
    transition: background-color 0.15s, border-color 0.15s;
}

.kp-options input[type="checkbox"] + .option-label::after {
    border-radius: 6px;
}

.kp-options input:checked + .option-label {
    border-color: var(--kp-primary);
    background: var(--kp-primary-soft);
    box-shadow: 0 0 0 1px var(--kp-primary) inset;
}

.kp-options input:checked + .option-label::after {
    border-color: var(--kp-primary);
    background-color: var(--kp-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.kp-options input:focus-visible + .option-label {
    outline: 3px solid rgba(79, 138, 54, 0.35);
    outline-offset: 2px;
}

/* Text answers */
.kp-step-input,
.kp-step-final input[type="text"],
.kp-step-final input[type="tel"],
.kp-step-final input[type="email"],
.kp-step-final input[type="password"],
.kp-step-final input[type="date"],
.kp-step-final select,
.kp-step-final textarea {
    width: 100%;
    min-height: 50px;
    padding: 0.7rem 1rem;
    border: 1.5px solid #d3dbe1;
    border-radius: 10px;
    background: #ffffff;
    color: var(--kp-text);
    font-size: 1rem;
    box-shadow: none;
    box-sizing: border-box;
}

.kp-step-final textarea,
textarea.kp-step-input {
    min-height: 110px;
    resize: vertical;
}

.kp-step-input:focus,
.kp-step-final input:focus,
.kp-step-final select:focus,
.kp-step-final textarea:focus {
    outline: none;
    border-color: var(--kp-primary);
    box-shadow: 0 0 0 3px rgba(79, 138, 54, 0.15);
}

/* flatpickr visible input */
.kp-step-final input.flatpickr-input.form-control,
.kp-step-final input.flatpickr-input + input {
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6d5a' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") no-repeat right 0.9rem center / 20px;
    cursor: pointer;
}

/* ---------- Navigation ---------- */
.kp-step-nav {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--kp-border);
}

.kp-step-nav #nextBtn {
    margin-left: auto;
    min-width: 160px;
}

.kp-step-nav .kp-btn,
.kp-step-nav .kp-btn-ghost {
    height: 48px;
    padding: 0 1.5rem;
}

/* ---------- Final step ---------- */
.kp-step-final-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.5rem;
    align-items: start;
}

.kp-step-final-head {
    margin-bottom: 1.25rem;
}

.kp-step-final-head h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
}

.kp-step-final-head p {
    margin: 0.2rem 0 0;
    color: var(--kp-muted);
}

.kp-step-final .kp-field label {
    font-size: 0.75rem;
}

/* Boxes (existing account, SMS code, new account) */
.kp-step-box {
    margin-top: 1.25rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid #d3e6c6;
    border-radius: 12px;
    background: #f7fbf4;
}

.kp-step-box.is-error,
.otpSection.is-error {
    border-color: #f1b7ac;
    background: #fdf1ee;
}

.kp-step-box-title {
    margin: 0 0 0.2rem;
    font-weight: 700;
}

.kp-step-box-text {
    margin: 0 0 0.75rem;
    color: var(--kp-muted);
    font-size: 0.9rem;
}

.kp-step-box .wlcxx {
    margin-bottom: 1rem;
}

.kp-step-box .wlcxx h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.kp-step-box .wlcxx p {
    margin: 0.15rem 0 0;
    color: var(--kp-muted);
    font-size: 0.9rem;
}

.kp-step-otp-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.kp-step-otp-row input {
    flex: 1;
    min-width: 0;
    letter-spacing: 4px;
    font-size: 1.15rem !important;
    text-align: center;
}

.kp-step-otp-row .kp-btn {
    flex-shrink: 0;
    min-height: 50px;
}

.kp-step-status {
    margin: 0.6rem 0 0;
    font-size: 0.88rem;
}

.kp-step-status:empty {
    display: none;
}

.kp-step-status .text-success,
.kp-step-status.text-success {
    color: var(--kp-primary-dark) !important;
}

.kp-step-countdown {
    font-weight: 600;
    color: var(--kp-primary-dark);
}

.kp-step-countdown.is-expired {
    color: var(--kp-red);
}

#checkPhoneNote {
    margin: 0 0 0.25rem;
}

#sendOtpBtn {
    width: 100%;
    min-height: 48px;
}

/* "Vérification obligatoire" hint (step_script_otp.php) */
.otp-notice {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--kp-red);
    font-size: 0.88rem;
    font-weight: 700;
}

.shine-btn {
    position: relative;
    overflow: hidden;
    border-color: var(--kp-red) !important;
}

.shine-btn::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.8);
    transform: rotate(30deg);
    animation: kp-shine 1.5s infinite;
}

@keyframes kp-shine {
    0%   { left: -60%; }
    100% { left: 120%; }
}

/* Errors */
@keyframes kp-pulse-error {
    0%   { box-shadow: 0 0 0 0 rgba(217, 58, 31, 0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(217, 58, 31, 0); }
    100% { box-shadow: 0 0 0 0 rgba(217, 58, 31, 0); }
}

.highlight-error {
    border-color: var(--kp-red) !important;
    animation: kp-pulse-error 1.5s 2;
}

/* ---------- Summary ---------- */
.kp-step-recap {
    position: sticky;
    top: calc(var(--kp-header-h) + 1.5rem);
    padding: 1.5rem;
}

#showanswers h3 {
    margin: 0 0 0.4rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.kp-recap-intro {
    margin: 0 0 1rem;
    color: var(--kp-muted);
    font-size: 0.9rem;
}

.kp-recap-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.kp-recap-list li {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: #f5f8f3;
}

.kp-recap-list b {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--kp-muted);
}

.kp-recap-list span {
    display: block;
    margin-top: 0.1rem;
    font-weight: 600;
}

.wrap-text {
    overflow-wrap: anywhere;
    white-space: normal;
}

.kp-recap-edit {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
}

.noteer {
    margin: 1.25rem 0 0.75rem;
    color: var(--kp-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.noteer .condi {
    color: var(--kp-primary-dark);
    font-weight: 600;
}

.kp-step-recap #mainSubmitBtn {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
    font-weight: 700;
}

.kp-step-recap #mainSubmitBtn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.kp-step-secure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.75rem 0 0;
    color: var(--kp-muted);
    font-size: 0.82rem;
}

.kp-step-secure svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ---------- flatpickr colours ---------- */
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    border-color: var(--kp-primary);
    background: var(--kp-primary);
}

.flatpickr-day.today {
    border-color: var(--kp-primary);
}

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .kp-step-final-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .kp-step-recap {
        position: static;
    }
}

@media (max-width: 798.98px) {
    .kp-step-hero {
        padding: 1.1rem 1.25rem;
    }

    .kp-step-hero-img {
        width: 52px;
        height: 52px;
    }

    .kp-step-hero h2 {
        font-size: 1.3rem;
    }

    .kp-step-change {
        display: none;
    }

    .kp-step-card {
        padding: 1.25rem;
    }

    .step legend h3 {
        font-size: 1.15rem;
    }

    .kp-options {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    /* Navigation stays reachable above the mobile bottom bar */
    body.kp-client:not(.kp-step-guest) .kp-step-nav {
        position: sticky;
        bottom: calc(var(--kp-bottombar-h) + env(safe-area-inset-bottom));
        z-index: 5;
        margin: 1.25rem -1.25rem -1.25rem;
        padding: 0.85rem 1.25rem;
        background: #ffffff;
        box-shadow: 0 -4px 12px rgba(31, 56, 22, 0.06);
    }

    .kp-step-guest .kp-step-nav {
        position: sticky;
        bottom: 0;
        z-index: 5;
        margin: 1.25rem -1.25rem -1.25rem;
        padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom));
        background: #ffffff;
        box-shadow: 0 -4px 12px rgba(31, 56, 22, 0.06);
    }

    .kp-step-nav .kp-btn,
    .kp-step-nav .kp-btn-ghost {
        flex: 1;
        min-width: 0;
    }

    .kp-step-otp-row {
        flex-direction: column;
    }
}

/* Global styles of the old form can add floats / margins to .option */
.kp-options .option {
    float: none !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.kp-step-final textarea,
.kp-step-input,
.kp-step-final input,
.kp-step-final select {
    font-family: inherit;
}

body.kp-step-guest {
    font-family: 'Roboto', 'Montserrat', Arial, sans-serif;
}

.kp-options .option-label {
    box-sizing: border-box;
    height: 100%;
    min-height: 64px;
}

.kp-options .option {
    display: flex;
}

.kp-options .option-label {
    flex: 1;
}

/* ---------- Answer tiles: equal spacing, no overlap ----------
   Long labels ("Appartement") were wider than their column and ran
   under the next tile. Columns are now wider, and tiles may shrink/wrap. */
.step .ans.kp-options {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 14px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
}

.kp-options .option {
    min-width: 0 !important;
    max-width: 100% !important;
}

.kp-options .option-label {
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    margin: 0 !important;
    gap: 0.85rem;
    padding: 0.85rem 1rem !important;
}

.kp-options .option-label span {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.kp-options .option-icon {
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
}

.kp-options .option-label::after {
    margin-left: 0;
}

@media (max-width: 798.98px) {
    .step .ans.kp-options {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* ---------- Visitor header ---------- */
.kp-guest-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    box-shadow: 0 1px 6px rgba(31, 56, 22, 0.06);
}

.kp-guest-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1180px;
    height: 72px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.kp-guest-logo img {
    display: block;
    height: 46px;
    width: auto;
}

.kp-guest-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.kp-guest-phone {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--kp-text);
    font-weight: 600;
    text-decoration: none;
}

.kp-guest-phone svg {
    width: 18px;
    height: 18px;
    stroke: var(--kp-primary-dark);
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
}

.kp-guest-login {
    padding: 0.55rem 1.1rem;
    border: 2px solid var(--kp-primary);
    border-radius: 100px;
    color: var(--kp-primary-dark);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
}

.kp-guest-login:hover {
    background: var(--kp-primary);
    color: #ffffff;
    text-decoration: none;
}

@media (max-width: 575.98px) {
    .kp-guest-header-inner {
        height: 60px;
    }

    .kp-guest-logo img {
        height: 36px;
    }

    .kp-guest-phone span {
        display: none;
    }

    .kp-guest-login {
        padding: 0.45rem 0.85rem;
        font-size: 0.82rem;
    }
}

.kp-guest-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    padding: 1.5rem 1rem 2.5rem;
    color: var(--kp-muted);
    font-size: 0.85rem;
}

.kp-guest-footer a {
    color: var(--kp-muted);
}

/* Visitors: centred page, no sidebar */
.kp-step-guest .kp-step-guest-main {
    margin: 0 auto;
}

/* ---------- Mobile: Retour / Suivante always fixed at the bottom ---------- */
@media (max-width: 798.98px) {
    .kp-step-guest .kp-step-nav,
    body.kp-client:not(.kp-step-guest) .kp-step-nav {
        position: fixed !important;
        left: 0;
        right: 0;
        margin: 0 !important;
        padding: 0.75rem 1rem !important;
        border-top: 1px solid var(--kp-border);
        background: #ffffff;
        box-shadow: 0 -4px 14px rgba(31, 56, 22, 0.08);
        z-index: 1001;
    }

    /* Visitors: very bottom of the screen */
    .kp-step-guest .kp-step-nav {
        bottom: 0;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
    }

    /* Logged in: just above the app bottom bar */
    body.kp-client:not(.kp-step-guest) .kp-step-nav {
        bottom: calc(var(--kp-bottombar-h) + env(safe-area-inset-bottom));
    }

    /* Room so the last answers are not hidden behind the bar */
    #haveAllQuestions {
        padding-bottom: 5.5rem;
    }

    .kp-step-guest .kp-guest-footer {
        padding-bottom: 6rem;
    }
}
