/*
 * ECOROOM — écrans d'authentification (espace équipe et portail client).
 * Feuille autonome : ne dépend ni de Tailwind ni de Vite, compatible avec la CSP (font-src 'self').
 * Couleurs reprises du logo : orange #FF9A00 et noir. Polices : Bricolage Grotesque et Figtree (SIL OFL 1.1).
 */

@font-face {
    font-family: "Bricolage";
    src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2");
    font-weight: 300 900;
    font-display: swap;
}

:root {
    --orange: #ff9a00;
    --orange-hover: #f08c00;
    --orange-texte: #b45f00;          /* orange lisible sur blanc */
    --orange-anneau: rgba(255, 154, 0, 0.32);
    --noir: #17140f;
    --texte: #1c1917;
    --ardoise: #6b645e;
    --trait: #e7e3df;
    --trait-fort: #d3cdc7;
    --fond: #ffffff;
    --fond-doux: #faf9f7;
    --erreur: #b42318;
    --erreur-fond: #fef3f2;
    --succes: #067647;
    --succes-fond: #ecfdf3;

    --rayon: 10px;
    --display: "Bricolage", "Segoe UI", system-ui, sans-serif;
    --texte-famille: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body.auth {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--fond);
    color: var(--texte);
    font-family: var(--texte-famille);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Structure ─────────────────────────────────────────────────────── */

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 11fr) minmax(0, 13fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.auth-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.25rem clamp(2rem, 4vw, 3.75rem) 2.75rem;
    color: #ffffff;
    background-color: var(--noir);
    background-image:
        linear-gradient(180deg, rgba(23, 20, 15, 0.35) 0%, rgba(23, 20, 15, 0.5) 38%, rgba(23, 20, 15, 0.94) 100%),
        url("panneau.jpg");
    background-size: cover;
    background-position: 70% center;
    overflow: hidden;
}

.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem clamp(1.25rem, 5vw, 4rem) 2rem;
}

.auth-form-wrap {
    width: 100%;
    max-width: 25rem;
    margin: auto 0;
}

.auth-footer {
    margin-top: 2.5rem;
    font-size: 0.8125rem;
    color: var(--ardoise);
    text-align: center;
}

.auth-footer p {
    margin: 0;
}

.aide-mobile {
    display: none;
    margin-bottom: 0.625rem !important;
    font-size: 0.9375rem;
}

/* ── Panneau photo ─────────────────────────────────────────────────── */

.panel-espace {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4375rem 0.875rem 0.4375rem 0.75rem;
    border-radius: 999px;
    background: rgba(23, 20, 15, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 0.875rem;
    font-weight: 600;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.panel-espace::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
}

.panel-bas {
    max-width: 30rem;
}

.panel-titre {
    margin: 0 0 1rem;
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(2.25rem, 3.3vw, 3.125rem);
    line-height: 1.04;
    letter-spacing: -0.025em;
    color: #ffffff;
    text-wrap: balance;
}

.panel-texte {
    margin: 0 0 1.75rem;
    font-size: 1.0625rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.8);
    max-width: 27rem;
}

/* ── Le carnet Marché Plus : 31 cases numérotées ──────────────────── */

.carnet {
    margin: 0;
    max-width: 23rem;
}

.carnet-grille {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.carnet-case {
    aspect-ratio: 1;
    padding: 5px 6px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(23, 20, 15, 0.28);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.6);
}

.carnet-case.est-paye {
    animation: case-remplie 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
    animation-delay: calc(var(--i) * 34ms + 300ms);
}

.carnet-case.est-commission {
    border: 1.5px dashed var(--orange);
    color: var(--orange);
}

@keyframes case-remplie {
    from {
        background: rgba(23, 20, 15, 0.28);
        border-color: rgba(255, 255, 255, 0.3);
        color: rgba(255, 255, 255, 0.6);
        transform: scale(0.86);
    }
    to {
        background: var(--orange);
        border-color: var(--orange);
        color: var(--noir);
        transform: scale(1);
    }
}

.carnet-legende {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.72);
}

.legende-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.legende-pastille {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--orange);
}

.legende-pastille.est-commission {
    background: transparent;
    border: 1.5px dashed var(--orange);
}

.panel-aide {
    margin: 1.75rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.panel-aide a {
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid var(--orange);
}

/* ── En-tête du formulaire : logo, titre, introduction ─────────────── */

.form-entete {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: block;
    width: 140px;
    height: 140px;
    margin: -0.5rem auto 1rem;
    object-fit: contain;
}

.logo-texte {
    display: inline-block;
    margin-bottom: 1.25rem;
    font-family: var(--display);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--noir);
}

.form-titre {
    margin: 0 0 0.5rem;
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(1.625rem, 2.2vw, 2rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: var(--texte);
}

.form-intro {
    margin: 0 auto;
    max-width: 22rem;
    color: var(--ardoise);
    font-size: 0.9875rem;
}

/* ── Messages ──────────────────────────────────────────────────────── */

.alerte {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin: 0 0 1.5rem;
    padding: 0.875rem 1rem;
    border-radius: var(--rayon);
    font-size: 0.9375rem;
    line-height: 1.45;
}

.alerte svg {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.alerte p {
    margin: 0;
}

.alerte p + p {
    margin-top: 0.25rem;
}

.alerte--erreur {
    background: var(--erreur-fond);
    color: var(--erreur);
    border: 1px solid #fecdca;
}

.alerte--succes {
    background: var(--succes-fond);
    color: var(--succes);
    border: 1px solid #abefc6;
}

/* ── Champs ────────────────────────────────────────────────────────── */

.formulaire {
    display: grid;
    gap: 1.25rem;
}

.champ {
    display: grid;
    gap: 0.4375rem;
}

.champ-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--texte);
}

.champ-label a {
    font-weight: 500;
    font-size: 0.875rem;
}

.champ-aide {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--ardoise);
}

.saisie {
    display: block;
    width: 100%;
    height: 3rem;
    padding: 0 0.875rem;
    border: 1px solid var(--trait-fort);
    border-radius: var(--rayon);
    background: var(--fond);
    color: var(--texte);
    font: inherit;
    font-size: 1rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.saisie::placeholder {
    color: #a8a29e;
}

.saisie:hover {
    border-color: #a8a29e;
}

.saisie:focus {
    outline: none;
    border-color: var(--orange-hover);
    box-shadow: 0 0 0 3px var(--orange-anneau);
}

.saisie[aria-invalid="true"] {
    border-color: var(--erreur);
}

.saisie[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.18);
}

/* Téléphone : indicatif + numéro dans un seul cadre */
.tel {
    display: flex;
    align-items: stretch;
    height: 3rem;
    border: 1px solid var(--trait-fort);
    border-radius: var(--rayon);
    background: var(--fond);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.tel:hover {
    border-color: #a8a29e;
}

.tel:focus-within {
    border-color: var(--orange-hover);
    box-shadow: 0 0 0 3px var(--orange-anneau);
}

.tel.est-invalide {
    border-color: var(--erreur);
}

.tel .saisie {
    height: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.tel .saisie:focus {
    box-shadow: none;
}

.tel .tel-indicatif {
    flex: none;
    width: 5.5rem;
    padding: 0 0.5rem 0 0.875rem;
    border-right: 1px solid var(--trait);
    background: var(--fond-doux);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    border-radius: var(--rayon) 0 0 var(--rayon);
}

.tel .saisie:last-child {
    border-radius: 0 var(--rayon) var(--rayon) 0;
}

/* Mot de passe avec bouton afficher */
.mdp {
    position: relative;
}

.mdp .saisie {
    padding-right: 6.25rem;
}

.mdp-bascule {
    position: absolute;
    top: 50%;
    right: 0.375rem;
    transform: translateY(-50%);
    height: 2.25rem;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ardoise);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.mdp-bascule:hover {
    background: #f3f1ee;
    color: var(--texte);
}

.mdp-bascule:focus-visible {
    outline: 2px solid var(--orange-hover);
    outline-offset: 1px;
}

.maj-alerte {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--orange-texte);
}

/* Code PIN : 6 chiffres bien espacés */
.saisie--pin {
    height: 3.5rem;
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: 0.55em;
    text-indent: 0.55em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.saisie--pin::placeholder {
    letter-spacing: 0.55em;
    color: #d6d3d1;
    font-weight: 500;
}

/* Exigences du mot de passe */
.exigences {
    display: grid;
    gap: 0.25rem;
    margin: 0.125rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--ardoise);
}

.exigences li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.exigences li::before {
    content: "";
    width: 14px;
    height: 14px;
    flex: none;
    border-radius: 50%;
    border: 1.5px solid var(--trait-fort);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.exigences li.est-ok {
    color: var(--succes);
}

.exigences li.est-ok::before {
    border-color: var(--succes);
    background: var(--succes)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2 6 9.6l4.6-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        center / 12px no-repeat;
}

/* Case à cocher */
.coche {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9375rem;
    color: var(--texte);
    cursor: pointer;
    user-select: none;
}

.coche input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--orange-hover);
    cursor: pointer;
}

.ligne-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Étapes (création et réinitialisation du mot de passe) : une vraie séquence */
.etape {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.etape + .etape {
    padding-top: 1.5rem;
    border-top: 1px solid var(--trait);
}

.etape-titre {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-family: var(--display);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--texte);
}

.etape-num {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--noir);
    color: #ffffff;
    font-family: var(--texte-famille);
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── Bouton principal ──────────────────────────────────────────────── */

.bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    height: 3.125rem;
    margin-top: 0.5rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: var(--rayon);
    background: var(--orange);
    color: var(--noir);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(23, 20, 15, 0.12), inset 0 -2px 0 rgba(23, 20, 15, 0.12);
    transition: background-color 120ms ease, transform 80ms ease;
}

.bouton:hover {
    background: var(--orange-hover);
}

.bouton:active {
    transform: translateY(1px);
}

.bouton:focus-visible {
    outline: 3px solid var(--orange-anneau);
    outline-offset: 2px;
}

.bouton[disabled] {
    cursor: progress;
    opacity: 0.85;
}

.bouton-roue {
    display: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: roue 700ms linear infinite;
}

.bouton.est-en-cours .bouton-roue {
    display: inline-block;
}

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

/* ── Liens et pied de formulaire ───────────────────────────────────── */

.lien {
    color: var(--texte);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 2px solid var(--orange);
}

.lien:hover {
    color: var(--orange-texte);
}

.lien:focus-visible {
    outline: 2px solid var(--orange-hover);
    outline-offset: 2px;
    border-radius: 2px;
}

.renvoi {
    margin: 2rem 0 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--trait);
    font-size: 0.9375rem;
    color: var(--ardoise);
    text-align: center;
}

.renvoi p {
    margin: 0;
}

.renvoi p + p {
    margin-top: 0.625rem;
}

.note {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0 0;
    padding: 0.875rem 1rem;
    border-radius: var(--rayon);
    background: var(--fond-doux);
    border: 1px solid var(--trait);
    font-size: 0.875rem;
    color: #44403c;
}

.note svg {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    color: var(--ardoise);
}

.note p {
    margin: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Mobile et tablette ────────────────────────────────────────────── */

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    /* Sur téléphone, le formulaire passe en premier : le panneau photo disparaît */
    .auth-panel {
        display: none;
    }

    body.auth {
        border-top: 4px solid var(--orange);
    }

    .auth-main {
        padding-top: 1.75rem;
    }

    .logo {
        width: 120px;
        height: 120px;
        margin-bottom: 0.75rem;
    }

    .aide-mobile {
        display: block;
    }
}

@media (max-width: 380px) {
    .tel .tel-indicatif {
        width: 4.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .carnet-case.est-paye {
        animation-duration: 1ms;
        animation-delay: 0ms;
    }

    .bouton-roue {
        animation-duration: 1.6s;
    }

    .saisie,
    .tel,
    .bouton {
        transition: none;
    }
}

/* Écrans d'ordinateur peu hauts (1366×768, etc.) : le carnet et le titre se resserrent */
@media (min-width: 901px) and (max-height: 820px) {
    .auth-panel {
        padding-top: 1.75rem;
        padding-bottom: 2rem;
    }

    .panel-titre {
        font-size: clamp(1.875rem, 2.8vw, 2.5rem);
        margin-bottom: 0.75rem;
    }

    .panel-texte {
        margin-bottom: 1.25rem;
    }

    .carnet {
        max-width: 17.5rem;
    }

    .carnet-grille {
        gap: 4px;
    }

    .panel-aide {
        margin-top: 1.25rem;
        padding-top: 1rem;
    }
}
