/* ============================================================
   auth-feedback.css - error / feedback components for Login and Verify2FA.

   .auth-alert       form-level banner, when the culprit field is unknown:
                     bad credentials, blocked account, expired code.
   .auth-field-error field-level, only when we know which field is wrong.

   A credential failure is form-level only: the server cannot tell whether
   the email or the password was wrong, so neither field gets blamed.

   Prefixed `auth-` because global !important rules in site.css hijack
   Bootstrap's .is-invalid / .invalid-feedback.
   ============================================================ */

:root {
    --auth-danger: #d92d20;
    --auth-danger-bg: #fef3f2;
    --auth-danger-border: #fecdca;
    --auth-warning: #b54708;
    --auth-warning-bg: #fffaeb;
    --auth-warning-border: #fedf89;
    --auth-success: #067647;
    --auth-success-bg: #ecfdf3;
    --auth-success-border: #abefc6;
    --auth-info: #026aa2;
    --auth-info-bg: #f0f9ff;
    --auth-info-border: #b9e6fe;
    --auth-accent: #008aad;
}

/* ------------------------------------------------------------
   1. Form-level banner
   ------------------------------------------------------------ */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--auth-danger-border);
    border-left-width: 3px;
    border-radius: 8px;
    background: var(--auth-danger-bg);
    color: var(--auth-danger);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    animation: authAlertIn 0.22s ease-out both;
}

    .auth-alert:focus {
        outline: none;
        box-shadow: 0 0 0 3px rgba(0, 138, 173, 0.18);
    }

    .auth-alert > i {
        flex: 0 0 auto;
        font-size: 15px;
        line-height: 1.35;
        margin-top: 1px;
    }

.auth-alert__body {
    flex: 1 1 auto;
    min-width: 0;
}

.auth-alert__title {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.auth-alert__text {
    display: block;
    color: #52525b;
}

/* Inline call-to-action inside a banner (e.g. "Renvoyer le code") */
.auth-alert__action {
    display: inline-block;
    margin-top: 6px;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

    .auth-alert__action:hover {
        opacity: 0.8;
    }

.auth-alert--warning {
    border-color: var(--auth-warning-border);
    background: var(--auth-warning-bg);
    color: var(--auth-warning);
}

.auth-alert--success {
    border-color: var(--auth-success-border);
    background: var(--auth-success-bg);
    color: var(--auth-success);
}

.auth-alert--info {
    border-color: var(--auth-info-border);
    background: var(--auth-info-bg);
    color: var(--auth-info);
}

@keyframes authAlertIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ------------------------------------------------------------
   2. Field-level state
   ------------------------------------------------------------ */
/* login.css styles the password box through an ID (#Utilisateur_MDP), which
   outranks any class rule - hence the ID-qualified variant below. */
body .login_fields input.auth-input--invalid,
body .login_fields #Utilisateur_MDP.auth-input--invalid {
    border-color: #fda29b;
    background: #fffbfa;
}

    /* outline:none - the UA focus ring is a black frame that reads louder than
       the red border; the box-shadow replaces it in the error colour. */
    body .login_fields input.auth-input--invalid:focus,
    body .login_fields #Utilisateur_MDP.auth-input--invalid:focus {
        outline: none;
        border-color: var(--auth-danger);
        box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.25);
    }

/* Reserved message row: always present, always one line tall, so a message
   appearing never pushes the fields or the submit button down. Copy in here
   must stay short enough not to wrap - a second line brings the shift back. */
.auth-msg-slot {
    min-height: 23px;
    padding-top: 6px;
}

.auth-field-error {
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--auth-danger);
    font-size: 12.5px;
    line-height: 1.35;
    text-align: left;
}

    .auth-field-error.is-shown {
        display: flex;
    }

    .auth-field-error > i {
        flex: 0 0 auto;
        font-size: 12px;
    }

/* Neutral hint (caps-lock). Shares the reserved row with the field error -
   the error wins when both apply, so the row never holds two lines. */
.auth-field-hint {
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--auth-warning);
    font-size: 12.5px;
    line-height: 1.35;
    text-align: left;
}

    .auth-field-hint.is-shown {
        display: flex;
    }

/* Server-rendered MVC validation messages. login.css targets
   `body .login .validation`, which matches nothing on this page, so these
   used to render as unstyled black text. */
.auth-validation .field-validation-error,
span.auth-validation {
    display: block;
    color: var(--auth-danger);
    font-size: 12.5px;
    line-height: 1.35;
}

/* Gaps trimmed by what the reserved rows cost, so spacing at rest is unchanged. */
body .login_fields .auth-field-group {
    margin-bottom: 4px;
}

body .login_fields .login_fields__submit {
    margin-top: 10px;
}

/* ------------------------------------------------------------
   3. Attention shake (form-level failure)
   ------------------------------------------------------------ */
.auth-shake {
    animation: authShake 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes authShake {
    0%, 100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(3px);
    }
}

/* ------------------------------------------------------------
   4. Segmented one-time-code input
   ------------------------------------------------------------ */
/* Grid, not flex: six equal columns shrink together on a narrow screen instead
   of overflowing. max-width 304 = 6x44 + 5x8, so desktop is unchanged. */
.auth-otp {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-width: 304px;
    margin: 0 auto;
}

.auth-otp__box {
    width: 100%;
    min-width: 0;
    height: 50px;
    padding: 0;
    border: 1px solid #d4d4d8;
    border-radius: 10px;
    background: #f4f4f5;
    color: #18181b;
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    -moz-appearance: textfield;
}

    .auth-otp__box::-webkit-outer-spin-button,
    .auth-otp__box::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    .auth-otp__box.is-filled {
        background: #ffffff;
        border-color: #a1a1aa;
    }

    .auth-otp__box:focus {
        outline: none;
        background: #ffffff;
        border-color: var(--auth-accent);
        box-shadow: 0 0 0 3px rgba(0, 138, 173, 0.15);
    }

.auth-otp--invalid .auth-otp__box {
    border-color: #fda29b;
    background: #fffbfa;
}

    .auth-otp--invalid .auth-otp__box:focus {
        border-color: var(--auth-danger);
        box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.25);
    }

.auth-otp--disabled .auth-otp__box {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ------------------------------------------------------------
   5. Disabled submit button
   ------------------------------------------------------------ */
body .login_fields__submit input[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

    body .login_fields__submit input[disabled]:hover {
        background: #008aad;
    }

/* ------------------------------------------------------------
   6. Reduced motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .auth-alert,
    .auth-shake {
        animation: none;
    }
}

/* ------------------------------------------------------------
   7. Touch / small screens
   ------------------------------------------------------------ */
@media (max-width: 576px) {
    /* 40x46 boxes were under the 44px tap-target minimum on both axes. */
    .auth-otp {
        gap: 6px;
        max-width: 100%;
    }

    .auth-otp__box {
        height: 54px;
        font-size: 22px;
    }
}

@media (max-width: 360px) {
    /* At 320px a 6px gap costs 30px of the 288px available, dropping each box
       under 44px wide. */
    .auth-otp {
        gap: 4px;
    }
}
