/* ============================================================
   AFR Simulateur – styles
   ============================================================ */

:root {
    --afr-blue:       #324269;
    --afr-blue-light: #3e5285;
    --afr-blue-pale:  #eef1f7;
    --afr-blue-mid:   #c8d3eb;
    --afr-green:      #2e7d32;
    --afr-green-bg:   #e8f5e9;
    --afr-grey:       #6b7280;
    --afr-grey-light: #f5f6fa;
    --afr-border:     #e2e6f0;
    --afr-red:        #c62828;
    --afr-radius:     10px;
    --afr-radius-lg:  16px;
    --afr-shadow:     0 8px 40px rgba(50,66,105,.18);
}

/* ── Wrapper global ──────────────────────────────── */
.afr-sim {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    font-family: inherit;
    font-size: 16px;        /* base fixe, indépendant du thème */
    border-radius: var(--afr-radius-lg);
    overflow: hidden;
    box-shadow: var(--afr-shadow);
}

/* ── Barre de progression ────────────────────────── */
.afr-sim__progress {
    height: 5px;
    background: var(--afr-border);
}

.afr-sim__progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--afr-blue), var(--afr-blue-light));
    transition: width .45s cubic-bezier(.4,0,.2,1);
    min-width: 0;
}

/* ── Corps du formulaire ─────────────────────────── */
.afr-sim__body {
    background: #fff;
    padding: 2.8rem 3rem;
}

/* ── Étapes ──────────────────────────────────────── */
.afr-sim__step { display: none; }
.afr-sim__step.active {
    display: block;
    animation: afrFadeIn .3s ease;
}

@keyframes afrFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* ── Titre ───────────────────────────────────────── */
.afr-sim__title {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--afr-blue);
    margin: 0 0 2rem;
    line-height: 1.2;
}

/* ── Fields ──────────────────────────────────────── */
.afr-sim__field {
    margin-bottom: 1.6rem;
    position: relative;
}

.afr-sim__field > label:first-child {
    display: block;
    font-size: .88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #3d4a63;
    margin-bottom: .65rem;
}

.req {
    color: var(--afr-red);
    margin-left: 4px;
    font-weight: 900;
    font-size: 1.1rem;
    vertical-align: middle;
    line-height: 1;
}

/* Champs obligatoires : filet gauche discret */
.afr-sim__field:has([required]:not([type="radio"]):not([type="checkbox"])) {
    padding-left: .6rem;
    border-left: 3px solid var(--afr-blue-mid);
    transition: border-color .2s;
}

.afr-sim__field:has([required]:focus) {
    border-left-color: var(--afr-blue);
}

/* Inputs */
.afr-sim__field input[type="text"],
.afr-sim__field input[type="email"],
.afr-sim__field input[type="tel"],
.afr-sim__field input[type="number"],
.afr-sim__field select,
.afr-sim__field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: .85rem 1.1rem;
    border: 2px solid var(--afr-border);
    border-radius: var(--afr-radius);
    font-size: 1rem;
    color: #1a1a2e;
    background: var(--afr-grey-light);
    transition: border-color .2s, box-shadow .2s, background .2s;
    appearance: none;
    -webkit-appearance: none;
}

.afr-sim__field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23324269' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 10px;
    padding-right: 2.6rem;
    background-color: var(--afr-grey-light);
}

.afr-sim__field input:focus,
.afr-sim__field select:focus,
.afr-sim__field textarea:focus {
    outline: none;
    border-color: var(--afr-blue);
    box-shadow: 0 0 0 4px rgba(50,66,105,.1);
    background: #fff;
}

.afr-sim__field textarea { resize: vertical; min-height: 90px; }

.afr-sim__hint {
    margin: .4rem 0 0;
    font-size: .75rem;
    color: var(--afr-grey);
}

/* Erreur */
.afr-sim__field--error {
    padding-left: .6rem;
    border-left: 3px solid var(--afr-red) !important;
}

.afr-sim__field--error input,
.afr-sim__field--error select,
.afr-sim__field--error textarea {
    border-color: var(--afr-red);
    background: #fff5f5;
}

.afr-sim__error {
    margin: .35rem 0 0;
    font-size: .75rem;
    color: var(--afr-red);
    font-weight: 800;
}

/* ── CARTES ───────────────────────────────────────── */
.afr-sim__cards {
    display: grid;
    gap: .65rem;
    grid-template-columns: repeat(5, 1fr);
}

.afr-sim__cards--sm { grid-template-columns: repeat(3, 1fr); }
.afr-sim__cards--4  { grid-template-columns: repeat(4, 1fr); }
.afr-sim__cards--xs {
    grid-template-columns: repeat(2, 1fr);
    max-width: 320px;
}

.afr-sim__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1.1rem .7rem .9rem;
    border: 2px solid var(--afr-border);
    border-radius: var(--afr-radius);
    cursor: pointer;
    background: #fff;
    text-align: center;
    transition: border-color .2s, background .2s, transform .15s, box-shadow .2s;
    position: relative;
    min-height: 88px;
}

.afr-sim__card:hover {
    border-color: var(--afr-blue-mid);
    background: var(--afr-blue-pale);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(50,66,105,.10);
}

/* Radio caché */
.afr-sim__card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
}

/* Carte sélectionnée */
.afr-sim__card:has(input:checked) {
    border-color: var(--afr-blue);
    background: var(--afr-blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50,66,105,.28);
}

.afr-sim__card:has(input:checked) .afr-sim__card-icon,
.afr-sim__card:has(input:checked) .afr-sim__card-text,
.afr-sim__card:has(input:checked) small {
    color: #fff !important;
}

/* Icône Material Symbol */
.afr-sim__card-icon {
    font-size: 2rem;
    line-height: 1;
    color: var(--afr-blue);
    transition: color .2s;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

.afr-sim__card:has(input:checked) .afr-sim__card-icon {
    font-variation-settings: 'FILL' 1, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

.afr-sim__card-text {
    font-size: 1.05rem;     /* ~17px sur base 16px */
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a2e;
    transition: color .2s;
}


.afr-sim__card-text small {
    display: block;
    font-size: .75rem;
    font-weight: 400;
    color: var(--afr-grey);
    margin-top: .25rem;
}

/* Erreur sur groupe carte */
.afr-sim__field--error .afr-sim__cards {
    outline: 2px solid #ef9a9a;
    outline-offset: 4px;
    border-radius: var(--afr-radius);
}

/* ── Grid row ─────────────────────────────────────── */
.afr-sim__row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.afr-sim__row--3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Résultat agence ─────────────────────────────── */
#sim-agency-searching {
    display: none;
    align-items: center;
    gap: .6rem;
    font-size: .85rem;
    color: var(--afr-grey);
    margin-top: .6rem;
}

#sim-agency-searching::before {
    content: '';
    display: inline-block;
    width: 15px; height: 15px;
    border: 2px solid var(--afr-blue-pale);
    border-top-color: var(--afr-blue);
    border-radius: 50%;
    animation: afrSpin .7s linear infinite;
    flex-shrink: 0;
}

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

#sim-agency-result {
    display: none;
    align-items: center;
    gap: .75rem;
    background: var(--afr-green-bg);
    border: 2px solid #a5d6a7;
    border-radius: var(--afr-radius);
    padding: .8rem 1rem;
    margin-top: .6rem;
}

.afr-sim__agency-found {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .88rem;
    color: var(--afr-green);
    font-weight: 500;
}

.afr-sim__agency-found svg { flex-shrink: 0; stroke: var(--afr-green); }
.afr-sim__agency-found strong { font-weight: 700; }

/* Message agence distante */
.afr-sim__agency-distant {
    display: none;
    align-items: center;
    gap: .75rem;
    background: var(--afr-blue-pale);
    border: 2px solid var(--afr-blue-mid);
    border-radius: var(--afr-radius);
    padding: .8rem 1rem;
    margin-top: .6rem;
    font-size: .88rem;
    color: var(--afr-blue);
    font-weight: 500;
}

.afr-sim__agency-distant svg {
    flex-shrink: 0;
    stroke: var(--afr-blue);
}

/* ── Co-emprunteur ───────────────────────────────── */
.afr-sim__coemp {
    display: none;
    margin-top: 2rem;
    padding-top: 1.6rem;
    border-top: 2px dashed var(--afr-blue-mid);
}

.afr-sim--with-coemprunteur .afr-sim__coemp {
    display: block;
}

.afr-sim__coemp-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--afr-blue);
    margin-bottom: 1.3rem;
    background: var(--afr-blue-pale);
    border-radius: var(--afr-radius);
    padding: .5rem .8rem;
}

.afr-sim__coemp-header .material-symbols-sharp {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Checkbox RGPD ───────────────────────────────── */
.afr-sim__field > label.afr-sim__checkbox {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
    font-size: .82rem;
    color: #555;
    margin-bottom: 0;
}

.afr-sim__checkbox input[type="checkbox"] {
    width: 18px; height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--afr-blue);
    cursor: pointer;
}

.afr-sim__checkbox span {
    font-size: .8rem;
    color: var(--afr-grey);
    line-height: 1.5;
}

.afr-sim__checkbox a { color: var(--afr-blue); }

/* Icône dans les boutons */
.afr-sim__btn .material-symbols-sharp {
    font-size: 1.1rem;
    line-height: 1;
    vertical-align: middle;
}

/* ── Réassurances ────────────────────────────────── */
.afr-sim__trust {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem 2rem;
    list-style: none;
    margin: 1.6rem 0 0;
    padding: 1.2rem 0 0;
    border-top: 1px solid var(--afr-border);
}

.afr-sim__trust li {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .73rem;
    font-weight: 600;
    color: var(--afr-grey);
    white-space: nowrap;
    line-height: 1;
    margin-bottom: 0 !important; /* reset textwidget li */
}

.afr-sim__trust li .material-symbols-sharp {
    font-size: 1rem;
    color: var(--afr-blue-mid);
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    flex-shrink: 0;
}

/* ── Navigation ──────────────────────────────────── */
.afr-sim__nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
    border-top: 1px solid var(--afr-border);
    padding-top: 1.4rem;
}

.afr-sim__btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .8rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: background .2s, transform .15s, box-shadow .2s;
}

.afr-sim__btn:active { transform: scale(.97); }

.afr-sim__btn--next,
.afr-sim__btn--submit {
    background: var(--afr-blue);
    color: #fff;
    box-shadow: 0 4px 16px rgba(50,66,105,.25);
    margin-left: auto;
}

.afr-sim__btn--next:hover,
.afr-sim__btn--submit:hover {
    background: var(--afr-blue-light);
    box-shadow: 0 6px 20px rgba(50,66,105,.35);
}

.afr-sim__btn--submit:disabled {
    opacity: .6;
    cursor: not-allowed;
    box-shadow: none;
}

.afr-sim__btn--prev {
    background: transparent;
    color: var(--afr-grey);
    border: 2px solid var(--afr-border);
    padding: .75rem 1.5rem;
}

.afr-sim__btn--prev:hover {
    border-color: var(--afr-blue);
    color: var(--afr-blue);
}

/* ── Écran de succès ─────────────────────────────── */
.afr-sim__step--success { display: none; }
.afr-sim__step--success.active { display: block; }

.afr-sim__success {
    text-align: center;
    padding: 3.5rem 2rem;
}

.afr-sim__success svg { margin-bottom: 1.2rem; }

.afr-sim__success h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--afr-green);
    margin: 0 0 .8rem;
}

.afr-sim__success p {
    font-size: 1rem;
    color: var(--afr-grey);
    max-width: 480px;
    margin: 0 auto .5rem;
    line-height: 1.65;
}

/* ── Indicateur d'étapes (breadcrumb) ───────────── */
.afr-sim__breadcrumb {
    background: #fff;
    padding: 1.4rem 3rem;
    border-bottom: 1px solid var(--afr-border);
}

.afr-sim__breadcrumb ol {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.afr-sim__step-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Ligne de connexion entre les étapes */
.afr-sim__step-item::before {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(-50% + 16px);
    right: calc(50% + 16px);
    height: 2px;
    background: var(--afr-border);
    transition: background .4s;
}

.afr-sim__step-item:first-child::before { display: none; }

.afr-sim__step-item.done::before,
.afr-sim__step-item.active::before { background: var(--afr-blue); }

/* Cercle numéroté */
.afr-sim__step-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--afr-border);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    margin-bottom: .45rem;
    transition: background .3s, border-color .3s;
}

.afr-sim__step-num {
    font-size: .72rem;
    font-weight: 700;
    color: var(--afr-grey);
    line-height: 1;
}

.afr-sim__step-check {
    font-size: 1rem;
    color: #fff;
    display: none;
    line-height: 1;
}

.afr-sim__step-label {
    font-size: .68rem;
    font-weight: 600;
    color: var(--afr-grey);
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: center;
    transition: color .3s;
    white-space: nowrap;
}

/* Étape active */
.afr-sim__step-item.active .afr-sim__step-dot {
    border-color: var(--afr-blue);
    background: var(--afr-blue);
    box-shadow: 0 0 0 4px rgba(50,66,105,.12);
}

.afr-sim__step-item.active .afr-sim__step-num  { color: #fff; }
.afr-sim__step-item.active .afr-sim__step-label { color: var(--afr-blue); font-weight: 700; }

/* Étape complétée */
.afr-sim__step-item.done .afr-sim__step-dot {
    border-color: var(--afr-blue);
    background: var(--afr-blue);
}

.afr-sim__step-item.done .afr-sim__step-num   { display: none; }
.afr-sim__step-item.done .afr-sim__step-check { display: block; }
.afr-sim__step-item.done .afr-sim__step-label { color: var(--afr-blue); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 680px) {
    .afr-sim__breadcrumb { padding: 1rem 1.2rem; }

    .afr-sim__step-item::before { top: 12px; }

    .afr-sim__step-dot { width: 26px; height: 26px; }

    .afr-sim__step-label { display: none; }

    .afr-sim__body { padding: 1.6rem 1rem; }

    .afr-sim__title { font-size: 1.25rem; }

    /* Annule le filet gauche sur mobile */
    .afr-sim__field:has([required]:not([type="radio"]):not([type="checkbox"])) {
        padding-left: 0;
        border-left: none;
    }

    .afr-sim__cards { grid-template-columns: repeat(2, 1fr); }
    .afr-sim__cards > .afr-sim__card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
        max-width: 200px;
        margin: 0 auto;
    }
    .afr-sim__cards--xs { grid-template-columns: repeat(2, 1fr); max-width: 100%; }
    .afr-sim__cards--4  { grid-template-columns: repeat(2, 1fr); }
    .afr-sim__row,
    .afr-sim__row--3 { grid-template-columns: 1fr; }

    /* Boutons nav : réduction du padding et texte sans retour à la ligne */
    .afr-sim__btn {
        padding: .75rem 1rem;
        font-size: .9rem;
        white-space: nowrap;
    }

    .afr-sim__btn--prev { padding: .7rem .9rem; }
}

/* ── Mobile ≤ 560px ──────────────────────────────── */
@media (max-width: 560px) {

    /* Cartes → liste pleine largeur, disposition horizontale */
    .afr-sim__cards,
    .afr-sim__cards--sm,
    .afr-sim__cards--4,
    .afr-sim__cards--xs {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: .5rem;
    }

    /* Carte en ligne : icône à gauche, texte au centre */
    .afr-sim__card {
        flex-direction: row;
        justify-content: flex-start;
        gap: .75rem;
        padding: .85rem 1.1rem;
        min-height: 0;
        text-align: left;
    }

    .afr-sim__card-icon {
        font-size: 1.4rem;
        flex-shrink: 0;
    }

    .afr-sim__card-text {
        font-size: .95rem;
        text-align: left;
    }

    /* Annule la règle "dernière carte orpheline centrée" */
    .afr-sim__cards > .afr-sim__card:last-child:nth-child(odd) {
        grid-column: auto;
        max-width: 100%;
        margin: 0;
    }

    /* Bloc agence trouvée */
    #sim-agency-result {
        flex-direction: column;
        align-items: flex-start;
        gap: .3rem;
        padding: .7rem .9rem;
    }

    .afr-sim__agency-found {
        flex-wrap: wrap;
        gap: .25rem;
        font-size: .85rem;
    }

    .afr-sim__agency-found svg { display: none; }

    /* Espacement uniforme entre tous les champs */
    .afr-sim__field { margin-bottom: .8rem; }
    .afr-sim__row,
    .afr-sim__row--3 { gap: 0; }
    .afr-sim__row .afr-sim__field,
    .afr-sim__row--3 .afr-sim__field { margin-bottom: .8rem; }

    /* Labels : suppression des majuscules et letter-spacing sur mobile */
    .afr-sim__field > label:first-child {
        text-transform: none;
        letter-spacing: 0;
        font-size: .82rem;
    }

    /* Suppression forcée du filet gauche sur mobile */
    .afr-sim__field,
    .afr-sim__field:has([required]:not([type="radio"]):not([type="checkbox"])) {
        padding-left: 0 !important;
        border-left: none !important;
    }

    /* Inputs & selects : hauteur réduite sur mobile */
    .afr-sim__field input[type="text"],
    .afr-sim__field input[type="email"],
    .afr-sim__field input[type="tel"],
    .afr-sim__field input[type="number"],
    .afr-sim__field select {
        height: 42px;
        padding: 0 1rem;
        font-size: .95rem;
    }

    .afr-sim__field textarea {
        min-height: 70px;
        padding: .6rem 1rem;
        font-size: .95rem;
    }

    /* Réassurances → grille 2×2 */
    .afr-sim__trust {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .6rem .5rem;
        justify-items: start;
    }

    .afr-sim__trust li {
        white-space: normal;
        font-size: .7rem;
    }

    /* Boutons de navigation : empilés */
    .afr-sim__nav {
        flex-direction: column-reverse;
        gap: .6rem;
    }

    .afr-sim__btn {
        width: 100%;
        justify-content: center;
        white-space: nowrap;
    }

    .afr-sim__btn--next,
    .afr-sim__btn--submit { margin-left: 0; }
}
