/**
 * Feuille de style du module d'authentification.
 *
 * Direction visuelle : « bureau de préfecture numérique » — sobriété
 * administrative assumée mais soignée. Fond ardoise très sombre, accent
 * bleu-encre, une seule police à empattements pour les titres (autorité,
 * papier officiel) et une sans-serif géométrique pour le corps (lisibilité
 * écran). Champs larges, focus très visible, pensé mobile d'abord.
 *
 * Aucune dépendance externe : tout est en CSS pur, responsive, et respecte
 * prefers-reduced-motion + focus clavier visible.
 */

:root {
    /* Palette : encre de bureau */
    --ink-900: #14161c;   /* fond profond */
    --ink-800: #1c1f28;   /* panneaux */
    --ink-700: #262a36;   /* bordures */
    --paper:   #f4f2ec;   /* texte clair, ton papier */
    --muted:   #9aa1b1;   /* texte secondaire */
    --accent:  #4c7ef3;   /* bleu-encre, actions */
    --accent-strong: #6b93ff;
    --danger:  #e2777a;   /* erreurs, ton brique doux */
    --success: #6fbf9b;   /* validations */

    --radius: 10px;
    --field-h: 3rem;
    --maxw: 27rem;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(120% 80% at 50% -10%, #1f2430 0%, var(--ink-900) 60%);
    color: var(--paper);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Carte centrale */
.auth-card {
    width: 100%;
    max-width: var(--maxw);
    background: var(--ink-800);
    border: 1px solid var(--ink-700);
    border-radius: var(--radius);
    padding: 2.25rem 2rem 2rem;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

/* En-tête : marque + titre */
.auth-brand {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.25rem;
}
.auth-brand-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--muted);
    transition: color 0.15s ease, border-color 0.15s ease;
}
.auth-brand-link:hover {
    color: var(--accent, #6366f1);
    border-color: currentColor;
}

.auth-title {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 0.35rem;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0 0 1.75rem;
}

/* Champs de formulaire */
.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.field input {
    width: 100%;
    height: var(--field-h);
    padding: 0 0.9rem;
    background: var(--ink-900);
    border: 1px solid var(--ink-700);
    border-radius: 8px;
    color: var(--paper);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder { color: #5b6172; }

.field input:focus {
    outline: none;
    border-color: var(--accent);
    /* Focus très visible, y compris au clavier */
    box-shadow: 0 0 0 3px rgba(76, 126, 243, 0.28);
}

/* Champ de code 2FA : chiffres espacés, façon coffre */
.field input.code {
    letter-spacing: 0.5em;
    text-align: center;
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
}

/* Bouton principal */
.btn {
    width: 100%;
    height: var(--field-h);
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
    outline: 3px solid rgba(107, 147, 255, 0.6);
    outline-offset: 2px;
}

/* Liens secondaires */
.auth-links {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
    color: var(--muted);
}

.auth-links a {
    color: var(--accent-strong);
    text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }

/* Messages (erreur / succès) */
.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(226, 119, 122, 0.12);
    border-color: rgba(226, 119, 122, 0.4);
    color: #f2b4b6;
}

.alert-success {
    background: rgba(111, 191, 155, 0.12);
    border-color: rgba(111, 191, 155, 0.4);
    color: #a7e0c8;
}

/* QR code du 2FA */
.qr-wrap {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    margin: 0 auto 1.25rem;
    width: fit-content;
}
.qr-wrap svg, .qr-wrap img { display: block; }

/* Codes de secours */
.recovery-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem 0 1.5rem;
    padding: 1rem;
    background: var(--ink-900);
    border: 1px dashed var(--ink-700);
    border-radius: 8px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-align: center;
}

/* Sélecteur de langue */
.lang-switch {
    margin-top: 1.75rem;
    text-align: center;
    font-size: 0.8rem;
}
.lang-switch a {
    color: var(--muted);
    text-decoration: none;
    padding: 0 0.35rem;
}
.lang-switch a.active { color: var(--paper); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Administration : la carte s'élargit pour accueillir un tableau.      */
/* ------------------------------------------------------------------ */

/* La page admin utilise une carte plus large que les formulaires. */
body.admin .auth-card,
.auth-card.wide {
    max-width: 48rem;
}

.admin-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
}
.admin-filters a {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--ink-700);
}
.admin-filters a.active {
    color: var(--paper);
    border-color: var(--accent);
    background: rgba(76, 126, 243, 0.12);
}

/* Le tableau défile horizontalement sur mobile plutôt que de déborder. */
.admin-table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
    text-align: left;
    padding: 0.7rem 0.6rem;
    border-bottom: 1px solid var(--ink-700);
    vertical-align: middle;
}
.admin-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.admin-table .u-email {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85rem;
}
.admin-table .u-username {
    font-size: 0.8rem;
    opacity: 0.65;
    margin-left: 0.3rem;
}
.badge-admin {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    border-radius: 4px;
    background: rgba(76, 126, 243, 0.18);
    color: var(--accent-strong);
    vertical-align: middle;
}

/* Zone d'actions : les mini-formulaires s'alignent côte à côte. */
.u-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.u-actions form { margin: 0; }

.btn-mini {
    height: auto;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--ink-700);
    border-radius: 6px;
    background: var(--ink-900);
    color: var(--paper);
    cursor: pointer;
    font-family: inherit;
}
.btn-mini:hover { border-color: var(--accent); }
.btn-mini.btn-danger { color: var(--danger); border-color: rgba(226, 119, 122, 0.4); }
.btn-mini.btn-danger:hover { border-color: var(--danger); }

/* Tableau de bord sécurité */
.security-app {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.75rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--ink-700);
}
.security-app:first-of-type { margin-top: 1rem; }
.security-table .security-value {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85rem;
    color: var(--accent-strong);
    text-align: right;
    white-space: nowrap;
}

/* Journal d'audit */
.audit-count {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0.5rem 0 1rem;
}
.audit-log {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--ink-900);
    border: 1px solid var(--ink-700);
    border-radius: 8px;
    padding: 0.75rem;
}
.audit-line {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--muted);
    border-left: 3px solid transparent;
}
.audit-line.lvl-info     { border-left-color: var(--ink-700); }
.audit-line.lvl-warning  { border-left-color: #d9a441; color: #e6c98a; background: rgba(217,164,65,0.06); }
.audit-line.lvl-critical { border-left-color: var(--danger); color: #f2b4b6; background: rgba(226,119,122,0.08); }

/* Accessibilité : on coupe les transitions si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Petits écrans */
@media (max-width: 420px) {
    .auth-card { padding: 1.75rem 1.25rem; }
    .auth-title { font-size: 1.5rem; }
}
