/**
 * Inscription B2B - styles front + header link.
 *   - Tuiles Particulier / Professionnel
 *   - Indicateurs de validation SIRET / TVA
 *   - Adresse INSEE en info text sous le SIRET (option A)
 *   - Pré-remplissage visuel
 *
 * @license GPL-3.0-or-later
 */

/* ── Tuiles bascule Particulier / Professionnel ─────────────────────── */
.b2r-account-type {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 0 0 22px;
}
.b2r-tile {
    position: relative;
    margin: 0;
    cursor: pointer;
    display: block;
}
.b2r-tile input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.b2r-tile-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    transition: all .15s ease;
    min-height: 78px;
}
.b2r-tile:hover .b2r-tile-inner {
    border-color: #cbd5e1;
    background: #f9fafb;
}
.b2r-tile input[type="radio"]:focus-visible + .b2r-tile-inner {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}
.b2r-tile input[type="radio"]:checked + .b2r-tile-inner {
    border-color: #2563EB;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .12);
}
.b2r-tile-pro input[type="radio"]:checked + .b2r-tile-inner {
    border-color: #f97316;
    background: #fff7ed;
    box-shadow: 0 2px 8px rgba(249, 115, 22, .15);
}
.b2r-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    flex: 0 0 auto;
    transition: all .15s ease;
}
.b2r-tile input[type="radio"]:checked + .b2r-tile-inner .b2r-tile-icon {
    background: #dbeafe;
    color: #1d4ed8;
}
.b2r-tile-pro input[type="radio"]:checked + .b2r-tile-inner .b2r-tile-icon {
    background: #fed7aa;
    color: #b45309;
}
.b2r-tile-body {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}
.b2r-tile-title {
    font-weight: 600;
    font-size: 15px;
    color: #111827;
}
.b2r-tile-sub {
    font-size: 12.5px;
    color: #6b7280;
    margin-top: 2px;
}

@media (max-width: 540px) {
    .b2r-account-type { grid-template-columns: 1fr; gap: 10px; }
    .b2r-tile-inner { padding: 14px 16px; min-height: 70px; }
}

/* ── Zone B2B (champs pro déplacés en haut, sous les tuiles) ────────── */
.b2r-pro-fields {
    margin: 0 0 22px;
    padding: 18px 18px 4px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    position: relative;
}
.b2r-pro-fields:empty { display: none; }
.b2r-pro-fields::before {
    content: "Informations professionnelles";
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #b45309;
    margin-bottom: 14px;
}
/* Le contexte "Informations professionnelles" + la tuile Pro déjà sélectionnée
   rendent le tag "Optionnel" redondant et confus. On le masque dans la zone B2B.
   Couvre les classes utilisées par Classic et autres thèmes courants. */
.b2r-pro-fields .optional,
.b2r-pro-fields .form-control-comment,
.b2r-pro-fields .form-text.text-muted {
    display: none !important;
}
/* Labels alignés à gauche dans la zone B2B (Classic 2.2.0 les met à droite). */
.b2r-pro-fields .form-control-label {
    text-align: left;
    margin-right: 10px;
    padding-right: 0;
}

/* Reveal progressif : tant que le SIRET n'est pas validé, on n'affiche QUE
   le champ SIRET. Les autres champs apparaissent une fois le SIRET validé
   (avec auto-remplissage déjà appliqué — effet "magique" UX). */
.b2r-pro-fields.b2r-await-siret:not(.b2r-foreign-mode) > .form-group:not(.b2r-group-siret) {
    display: none !important;
}

/* Mode étranger (toggle "Mon entreprise n'est pas en France") :
   SIRET caché, pays + raison sociale + TVA visibles d'office.
   APE est FR-only → caché en mode étranger aussi. */
.b2r-pro-fields.b2r-foreign-mode > .form-group.b2r-group-siret,
.b2r-pro-fields.b2r-foreign-mode > .form-group.b2r-group-ape,
.b2r-pro-fields.b2r-foreign-mode .b2r-await-hint {
    display: none !important;
}
/* En mode FR (par défaut), le pays reste caché — il vaut shop default côté DOM. */
.b2r-pro-fields:not(.b2r-foreign-mode) > .form-group.b2r-group-country {
    display: none !important;
}

/* Toggle "Pas de SIRET — entreprise hors France" — n'est utile QUE pendant
   l'attente de validation SIRET ou en mode étranger. Une fois le SIRET validé,
   le client n'a plus rien à faire ici, on le masque pour ne pas polluer. */
.b2r-foreign-toggle {
    display: inline-block;
    margin: 4px 0 14px;
    padding: 6px 0;
    font-size: 13px;
    color: #2563EB;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    cursor: pointer;
}
.b2r-pro-fields:not(.b2r-await-siret):not(.b2r-foreign-mode) .b2r-foreign-toggle {
    display: none;
}
.b2r-foreign-toggle:hover {
    color: #1d4ed8;
    border-bottom-style: solid;
}
/* En mode étranger, le toggle remonte légèrement au-dessus du pays */
.b2r-pro-fields.b2r-foreign-mode > .b2r-foreign-toggle {
    margin-bottom: 18px;
}
.b2r-pro-fields > .form-group.b2r-group-siret {
    margin-bottom: 0;
}
.b2r-pro-fields:not(.b2r-await-siret) > .form-group.b2r-group-siret {
    margin-bottom: 1rem;
}
/* Petit indice sous le SIRET en mode attente */
.b2r-await-hint {
    font-size: 12.5px;
    color: #475569;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0f9ff;
    border-left: 3px solid #38bdf8;
    border-radius: 0 6px 6px 0;
    line-height: 1.5;
}
.b2r-pro-fields:not(.b2r-await-siret) .b2r-await-hint { display: none; }

/* Erreur bloquante de soumission (en haut du form prepend). */
.b2r-submit-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin: 0 0 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 13.5px;
    font-weight: 500;
}
.b2r-submit-error::before {
    content: "!";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #dc2626;
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    flex: 0 0 auto;
}

/* ── Intro CMS bandeau ──────────────────────────────────────────────── */
.b2r-intro { display: flex; align-items: center; gap: 8px; }

/* ── CGV B2B (checkbox requis avant submit) ─────────────────────────── */
.b2r-terms { margin-top: 18px; }
.b2r-terms-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    line-height: 1.5;
    color: #334155;
    cursor: pointer;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin: 0;
}
.b2r-terms-label input[type="checkbox"] {
    margin-top: 3px;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.b2r-terms-label a {
    color: #2563EB;
    font-weight: 600;
    text-decoration: underline;
}
.b2r-terms-label a:hover { color: #1d4ed8; }

/* ── Statuts de validation — badges modernes ────────────────────────── */
.b2r-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    border-radius: 999px;
    border: 1px solid transparent;
    max-width: 100%;
    box-sizing: border-box;
}
.b2r-check:empty { display: none; }
.b2r-check::before {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.b2r-check-loading {
    color: #475569;
    background: #f1f5f9;
    border-color: #e2e8f0;
}
.b2r-check-loading::before {
    content: "";
    width: 12px; height: 12px;
    border: 2px solid #cbd5e1;
    border-top-color: #475569;
    border-radius: 50%;
    animation: b2r-spin .8s linear infinite;
}
@keyframes b2r-spin { to { transform: rotate(360deg); } }
.b2r-check-valid {
    color: #15803d;
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.b2r-check-valid::before {
    content: "\2713";
    color: #fff;
    background: #16a34a;
    font-weight: 700;
}
.b2r-check-invalid {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}
.b2r-check-invalid::before {
    content: "\2717";
    color: #fff;
    background: #dc2626;
    font-weight: 700;
}
.b2r-check-unknown {
    color: #b45309;
    background: #fffbeb;
    border-color: #fde68a;
}
.b2r-check-unknown::before {
    content: "!";
    color: #fff;
    background: #d97706;
    font-weight: 700;
}

/* ── Adresse INSEE sous le SIRET (option A : info uniquement) ───────── */
.b2r-insee-address {
    font-size: 12.5px;
    color: #475569;
    margin-top: 4px;
    padding: 8px 10px;
    background: #f8fafc;
    border-left: 3px solid #cbd5e1;
    border-radius: 0 4px 4px 0;
    line-height: 1.45;
}
.b2r-insee-address:empty { display: none; }
.b2r-insee-address-label {
    display: block;
    font-weight: 600;
    color: #334155;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 2px;
}

/* ── Pré-remplissage visuel ─────────────────────────────────────────── */
.b2r-autofilled {
    background-color: #f0fdf4;
    border-color: #86efac !important;
}
.b2r-autofill-hint {
    display: block;
    color: #15803d;
    font-size: 12px;
    margin-top: 2px;
}
