/* ═══════════════════════════════════════════════════════════════════════════
   Double authentification (2FA) — modales de déverrouillage, d'activation
   et d'association Authenticator. Préfixe : tf-
   ═══════════════════════════════════════════════════════════════════════════ */

.tf-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: tf-fade 0.18s ease-out;
}

.tf-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 2rem 1.75rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    background: var(--bg-card, #fff);
    color: var(--text-main, #0f172a);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    animation: tf-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tf-card.is-wide { max-width: 460px; }

.tf-close,
.tf-back {
    position: absolute;
    top: 14px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted, #64748b);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tf-close { right: 14px; }
.tf-back { left: 14px; }
.tf-close:hover,
.tf-back:hover { background: var(--bg-hover, #f1f5f9); color: var(--text-main, #0f172a); }

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.tf-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    text-align: center;
}

.tf-badge {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.75rem;
    color: var(--primary, #2563eb);
    background: color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--primary, #2563eb) 6%, transparent);
}
.tf-badge.is-success { color: #059669; background: rgba(16, 185, 129, 0.13); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0.07); }
.tf-badge.is-danger { color: #dc2626; background: rgba(239, 68, 68, 0.12); box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.06); }
.tf-badge.is-pulse { animation: tf-pulse 1.6s ease-in-out infinite; }

.tf-title {
    margin: 0.2rem 0 0;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--text-main, #0f172a);
}

.tf-lead {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-muted, #64748b);
}

/* ── Alertes ─────────────────────────────────────────────────────────────── */
.tf-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
}
.tf-alert i { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.tf-alert.is-error { background: rgba(239, 68, 68, 0.09); color: #dc2626; }
.tf-alert.is-warn { background: rgba(245, 158, 11, 0.1); color: #b45309; }

/* ── Sélecteur de méthode (segmenté) ─────────────────────────────────────── */
.tf-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--bg-hover, #f1f5f9);
}
.tf-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted, #64748b);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.tf-tab.is-active {
    background: var(--bg-card, #fff);
    color: var(--text-main, #0f172a);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* ── Saisie du code à 6 chiffres ─────────────────────────────────────────── */
.tf-otp {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}
.tf-otp input {
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1.2;
    padding: 0;
    border: 2px solid var(--border-color, #cbd5e1);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-main, #0f172a);
    font-size: 1.5rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: center;
    caret-color: var(--primary, #2563eb);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.tf-otp input:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary, #2563eb) 18%, transparent);
}
.tf-otp input:disabled { opacity: 0.6; }
.tf-otp.is-error input { border-color: #ef4444; animation: tf-shake 0.35s; }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.tf-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 12px;
    background: var(--primary, #2563eb);
    color: #fff;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
}
.tf-btn:hover:not(:disabled) { filter: brightness(1.08); }
.tf-btn:active:not(:disabled) { transform: translateY(1px); }
.tf-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.tf-btn.is-secondary {
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-main, #0f172a);
}

.tf-link {
    align-self: center;
    padding: 4px 8px;
    border: none;
    background: none;
    color: var(--text-muted, #64748b);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.tf-link:hover { color: var(--text-main, #0f172a); }
.tf-link.is-primary { color: var(--primary, #2563eb); }

/* ── Choix de méthode (activation) ───────────────────────────────────────── */
.tf-choices { display: flex; flex-direction: column; gap: 0.6rem; }
.tf-choice {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 14px;
    background: var(--bg-card, #fff);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.tf-choice:hover {
    border-color: var(--primary, #2563eb);
    background: color-mix(in srgb, var(--primary, #2563eb) 4%, var(--bg-card, #fff));
}
.tf-choice-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.35rem;
    color: var(--primary, #2563eb);
    background: color-mix(in srgb, var(--primary, #2563eb) 11%, transparent);
}
.tf-choice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tf-choice-title { font-size: 0.92rem; font-weight: 800; color: var(--text-main, #0f172a); }
.tf-choice-desc { font-size: 0.78rem; line-height: 1.35; color: var(--text-muted, #64748b); }
.tf-choice-arrow { color: var(--text-muted, #94a3b8); font-size: 1.15rem; }

/* ── Association Authenticator ───────────────────────────────────────────── */
.tf-step { display: flex; flex-direction: column; gap: 0.7rem; }
.tf-step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
}
.tf-step-num {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary, #2563eb);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
}
.tf-qr {
    align-self: center;
    width: 184px;
    height: 184px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 16px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: #fff;
    color: var(--text-muted, #64748b);
}
.tf-qr svg { width: 100%; height: 100%; }
.tf-secret {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    background: var(--bg-hover, #f1f5f9);
}
.tf-secret code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    word-break: break-all;
    color: var(--text-main, #0f172a);
}
.tf-secret button {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--primary, #2563eb);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.tf-field { display: flex; flex-direction: column; gap: 0.4rem; }
.tf-field label { font-size: 0.8rem; font-weight: 700; color: var(--text-main, #0f172a); }
.tf-field input[type="text"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--border-color, #cbd5e1);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-main, #0f172a);
    font: inherit;
    font-size: 0.92rem;
    box-sizing: border-box;
}
.tf-field input[type="text"]:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary, #2563eb) 18%, transparent);
}

/* ── Pied de carte ───────────────────────────────────────────────────────── */
.tf-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
}

.tf-center { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }

/* ── Mobile : la carte devient une feuille ancrée en bas ─────────────────── */
@media (max-width: 520px) {
    .tf-overlay { align-items: flex-end; padding: 0; }
    .tf-card {
        max-width: none;
        max-height: 92dvh;
        padding: 1.75rem 1.25rem 1.25rem;
        border-radius: 22px 22px 0 0;
        animation: tf-sheet 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    .tf-card.is-wide { max-width: none; }
}

@keyframes tf-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tf-pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes tf-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes tf-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes tf-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (prefers-reduced-motion: reduce) {
    .tf-overlay, .tf-card, .tf-badge.is-pulse, .tf-otp.is-error input { animation: none; }
}
