/* ==========================================================================
   Connexion et inscription — d'apres la planche « Ecrans-types /
   Authentification & etats systeme ».

   Feuille chargee par les deux seuls gabarits security/login.html.twig et
   security/register.html.twig. Ecrite contre public/css/tokens.css : aucune
   valeur de couleur brute.

   Le vocabulaire de forme est celui de security-password-reset.css — meme
   carte, meme echelle de titre, memes champs, memes regles de mot de passe :
   les trois ecrans d'authentification se suivent sans rupture.

   Deux differences assumees avec cette feuille voisine, parce que la planche
   les dessine ainsi : l'action principale est en encre (`--accent` vaut
   `--ink` hors module) et non en teinte Documents, et la carte porte la
   reglette des sept outils.
   ========================================================================== */

body {
    background: var(--canvas) !important;
    min-height: 100vh;
    display: flex !important;
    flex-direction: column !important;
}

.auth-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-5);
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-container--wide {
    max-width: 560px;
}

/* ---------- La carte -------------------------------------------------------- */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card-lg);
    padding: var(--space-8) var(--space-8) var(--space-6);
    box-shadow: var(--shadow-2);
}

.auth-title {
    font-family: var(--font-display);
    font-size: var(--text-title-1);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--track-title);
    line-height: var(--lh-snug);
    color: var(--ink);
    margin: 0;
}

.auth-text {
    font-size: 14px;
    line-height: var(--lh-loose);
    color: var(--ink-muted);
    margin: 6px 0 0;
}

.auth-link {
    color: var(--accent-ink);
    font-weight: var(--weight-medium);
    text-decoration: none;
}

.auth-link:hover { text-decoration: underline; }

.auth-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-chip);
}

/* ---------- Les outils gratuits, lus dans ModuleConfigService ---------------
   L'inscription annonce ce qui est reellement offert, avec sa limite. Jamais
   « sans limite de duree » : c'est la limite d'usage qui compte.
   -------------------------------------------------------------------------- */
.auth-free {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
}

.auth-free li {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-chip);
    background: var(--canvas);
    font-size: var(--text-xs);
    color: var(--ink-secondary);
}

.auth-free-name {
    font-weight: var(--weight-semibold);
    color: var(--ink);
}

.auth-free-limit { color: var(--ink-muted); }

/* ---------- Alertes ---------------------------------------------------------- */
.auth-alert {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    margin-top: var(--space-5);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-radius: 11px;
}

/* La note de l'outil choisi ne colle ni aux pastilles gratuites, ni a une
   alerte qui la precede. */
.auth-free + .ui-note {
    margin-top: var(--space-5);
}

.auth-alert + .ui-note {
    margin-top: var(--space-3);
}

.auth-alert--danger {
    background: var(--danger-tint);
    border-color: color-mix(in srgb, var(--danger) 28%, var(--surface));
}

.auth-alert--success {
    background: var(--success-tint);
    border-color: color-mix(in srgb, var(--success) 28%, var(--surface));
}

.auth-alert-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--ink-on-dark);
}

.auth-alert--danger .auth-alert-badge  { background: var(--danger); }
.auth-alert--success .auth-alert-badge { background: var(--success); }

.auth-alert-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--ink);
    margin: 0;
}

.auth-alert-text {
    font-size: 12.5px;
    line-height: var(--lh-normal);
    color: var(--ink-secondary);
    margin: 4px 0 0;
}

.auth-alert-actions {
    margin: var(--space-2) 0 0;
    font-size: 12.5px;
    color: var(--ink-secondary);
}

.auth-alert-actions a,
.auth-alert-text a {
    color: var(--danger-ink);
    font-weight: var(--weight-semibold);
    text-decoration: underline;
}

.auth-alert--success .auth-alert-text a { color: var(--success-ink); }

/* ---------- Formulaire -------------------------------------------------------- */
.auth-form { margin-top: var(--space-6); }

.form-group { margin-bottom: var(--space-4); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--ink-secondary);
    margin-bottom: 7px;
}

/* Le libelle et son raccourci (« Oublie ? ») sur la meme ligne. */
.form-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: 7px;
}

.form-label-row .form-label { margin-bottom: 0; }
.form-label-row .auth-link { font-size: 12.5px; }

.form-optional {
    font-weight: var(--weight-regular);
    color: var(--ink-muted);
}

/* La carte d'authentification est hors module : `--accent` y vaut l'encre.
   Un champ actif se signale en teinte Documents, comme sur l'ecran de
   reinitialisation, pour que les trois ecrans reagissent pareil. */
.auth-card .ui-input:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.ui-input--with-toggle { padding-right: 46px; }

.auth-hint {
    display: block;
    margin-top: 6px;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

.auth-hint--error {
    color: var(--danger);
    display: none;
}

.auth-hint--error.is-visible { display: block; }

.ui-input.is-invalid {
    border-color: var(--danger);
    border-width: 1.5px;
}

/* ---------- Afficher / masquer le mot de passe --------------------------------- */
.password-wrapper { position: relative; }

.password-toggle {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink-muted);
    transition: color var(--duration) var(--ease);
}

.password-toggle:hover { color: var(--ink); }

.password-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-chip);
}

.password-toggle svg {
    width: 17px;
    height: 17px;
}

/* L'oeil barre n'apparait qu'une fois le mot de passe revele. L'etat vit sur
   le wrapper, pas dans un style en ligne pose par le script. */
.password-toggle .eye-slash-icon { display: none; }
.password-wrapper.is-revealed .password-toggle .eye-icon { display: none; }
.password-wrapper.is-revealed .password-toggle .eye-slash-icon { display: block; }

/* ---------- Les cinq regles du serveur ------------------------------------------ */
.pwd-reqs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px var(--space-3);
    margin: 11px 0 0;
    padding: 0;
    list-style: none;
}

.pwd-req {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    color: var(--ink-muted);
    transition: color var(--duration) var(--ease);
}

.pwd-req .req-icon {
    font-weight: var(--weight-bold);
    color: var(--ink-disabled);
}

.pwd-req.valid { color: var(--success-ink); }
.pwd-req.valid .req-icon { color: var(--success); }

/* ---------- Acceptation des CGU --------------------------------------------------- */
.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: var(--space-5) 0 0;
}

.auth-consent input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.auth-consent input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--space-1);
}

.auth-consent label {
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
    color: var(--ink-secondary);
    cursor: pointer;
}

/* ---------- Actions ----------------------------------------------------------------- */
.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: var(--space-6);
    padding: 0 var(--space-4);
    background: var(--accent);
    color: var(--ink-on-dark);
    border: 1px solid var(--accent);
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    line-height: 1;
    /* Aussi posé sur un lien (« Connexion de l'équipe », invitation échue). */
    text-decoration: none;
    cursor: pointer;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.auth-submit:hover {
    background: color-mix(in srgb, var(--accent) 90%, var(--canvas));
    border-color: color-mix(in srgb, var(--accent) 90%, var(--canvas));
}

.auth-submit:disabled {
    opacity: 0.7;
    cursor: progress;
}

.auth-submit:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.auth-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    padding: 0 var(--space-4);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: 14.5px;
    font-weight: var(--weight-semibold);
    text-decoration: none;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.auth-secondary:hover {
    background: var(--surface-sunken);
    border-color: var(--ink);
    color: var(--ink);
}

.auth-secondary:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* ---------- Separateur « ou » ----------------------------------------------------------- */
.auth-sep {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0 18px;
}

.auth-sep::before,
.auth-sep::after {
    content: '';
    flex: 1 1 0;
    height: 1px;
    background: var(--border);
}

.auth-sep span {
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

/* ---------- Ce qui rassure, et qui est vrai ----------------------------------------------- */
.auth-reassure {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2) 18px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.auth-reassure li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ink-muted);
}

.auth-reassure i { color: var(--success); }

.auth-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 13.5px;
    color: var(--ink-muted);
}

/* ---------- La reglette des sept outils ------------------------------------------------------
   Le motif de marque de la planche. Decoratif : la sequence data-1..7 de
   tokens.css, posee par rang, sans une seule cle de module dans le balisage.
   -------------------------------------------------------------------------------------------- */
.auth-rule {
    display: flex;
    gap: 3px;
    margin-top: var(--space-6);
}

.auth-rule i {
    flex: 1 1 0;
    height: 4px;
    border-radius: 2px;
}

.auth-rule i:nth-child(1) { background: var(--data-1); }
.auth-rule i:nth-child(2) { background: var(--data-3); }
.auth-rule i:nth-child(3) { background: var(--data-2); }
.auth-rule i:nth-child(4) { background: var(--data-5); }
.auth-rule i:nth-child(5) { background: var(--data-7); }
.auth-rule i:nth-child(6) { background: var(--data-4); }
.auth-rule i:nth-child(7) { background: var(--data-6); }

/* ---------- Jusqu'a 390 px ------------------------------------------------------------------- */
@media (max-width: 560px) {
    .auth-wrapper { padding: var(--space-8) var(--space-4); }

    .auth-card { padding: var(--space-6) var(--space-5) var(--space-5); }

    .auth-title { font-size: var(--text-title-2); }

    .form-row { grid-template-columns: 1fr; gap: 0; }
}
