/* ============================================
   2FA Verification — Clean Minimal Design
   ============================================ */

/* Colores de marca: respaldo por si init/login_colores.php no llega a inyectar
   el <style> con los valores reales de EMPRESA. En el login el color DOMINANTE
   (encabezado, botón) es el secundario de EMPRESA (naranja por defecto); el
   primario de EMPRESA (azul por defecto) queda solo como acento en links. */
:root {
    --login-primary: #FF8C0F;
    --login-primary-dark: #A65B0A;
    --login-primary-light: #FFA94B;
    --login-primary-shadow: rgba(255, 140, 15, 0.15);
    --login-primary-shadow-strong: rgba(255, 140, 15, 0.35);
    --login-secondary: #165F83;
    --login-secondary-dark: #124C69;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    color: #333;
}

/* --- Wrapper --- */
.tfa-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

/* --- Card --- */
.tfa-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.08),
        0 2px 10px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Card Header (igual al login) --- */
.tfa-card-header {
    background: var(--login-primary);
    padding: 24px 40px 20px;
    text-align: center;
}

.tfa-card-header h3 {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* --- Card Body --- */
.tfa-card-body {
    padding: 24px 40px 32px;
}

/* --- Title & Subtitle --- */

.tfa-subtitle {
    font-size: 0.875rem;
    color: #a0aec0;
    text-align: center;
    margin-bottom: 4px;
    line-height: 1.5;
}

.tfa-phone {
    font-size: 1rem;
    color: #1a202c;
    font-weight: 600;
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 0.15em;
}

/* --- Label --- */
.tfa-card-body label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #718096;
    text-align: center;
}

/* --- Code Inputs --- */
.code-inputs {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
}

.code-inputs input {
    width: 56px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    color: #1a202c;
    border: 1px solid #e2e8f0;
    background: #fff;
    outline: none;
    border-radius: 10px;
    padding: 0;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    caret-color: var(--login-primary);
}

.code-inputs input:hover {
    border-color: #cbd5e0;
}

.code-inputs input:focus {
    border-color: var(--login-primary);
    box-shadow: 0 0 0 3px var(--login-primary-shadow);
}

.code-inputs input.filled {
    border-color: var(--login-primary);
    background: #f7fafc;
}

.code-inputs input.error-cell {
    border-color: #e53e3e;
    animation: shake 0.35s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* --- Timer --- */
.timer-row {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    font-size: 0.8rem;
    color: #a0aec0;
    margin-bottom: 6px;
    margin-top: 10px;
    padding: 0 4px;
}

#timer {
    font-weight: 600;
    color: var(--login-primary);
    letter-spacing: 0.04em;
}

#timer.expired {
    color: #e53e3e;
}

/* --- Message --- */
.msg-2fa {
    text-align: center;
    font-size: 0.8rem;
    font-style: normal;
    min-height: 22px;
    margin-bottom: 4px;
    transition: color 0.2s;
}

.msg-2fa.error {
    color: #e53e3e;
}

.msg-2fa.success {
    color: #38a169;
}

/* --- Button --- */
.btn-verify {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 18px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    color: #fff;
    background: var(--login-primary);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-verify:hover:not(:disabled) {
    background: var(--login-primary-dark);
}

.btn-verify:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Resend --- */
.resend-row {
    margin-top: 18px;
    font-size: 0.8rem;
    color: #a0aec0;
    text-align: center;
}

#btn-resend {
    background: none;
    border: none;
    color: var(--login-secondary);
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    transition: color 0.15s;
}

#btn-resend:hover:not(:disabled) {
    color: var(--login-secondary-dark);
}

#btn-resend:disabled {
    color: #cbd5e0;
    text-decoration: none;
    cursor: default;
}

/* --- Back Link --- */
.back-link {
    display: block;
    margin-top: 18px;
    font-size: 0.8rem;
    color: #a0aec0;
    text-decoration: none;
    text-align: center;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--login-secondary);
    text-decoration: underline;
}


.helper-text {
    margin: 6px 0 14px;
    color: #4a5568;
    font-size: 0.88rem;
    line-height: 1.4;
}

.msg-box {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.msg-box.ok {
    background: #ecfdf3;
    border: 1px solid #34d399;
    color: #065f46;
}

.msg-box.error {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.back-link {
    margin-top: 14px;
    text-align: center;
}

.back-link a {
    color: var(--login-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.back-link a:hover {
    text-decoration: underline;
}

.form-field {
    margin-bottom: 22px;
}

.form-field label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #4a5568;
    text-align: left;
}

.text-input {
    width: 100%;
    max-width: 420px;
    min-height: 56px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #1a202c;
    font-size: 1rem;
    padding: 0 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.text-input:focus {
    border-color: var(--login-primary);
    box-shadow: 0 0 0 3px var(--login-primary-shadow);
}

.helper-text {
    margin: 8px 0 18px;
    color: #718096;
    font-size: 0.88rem;
    line-height: 1.5;
}

.btn-verify {
    max-width: 420px;
    margin: 0 auto;
}

.tfa-subtitle {
    margin-bottom: 20px;
}

.form-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-container .form-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-container .form-field label {
    width: 100%;
    max-width: 420px;
}

.form-container .text-input {
    max-width: 420px;
}

.form-container .helper-text {
    max-width: 420px;
    text-align: center;
}

.form-container .btn-verify {
    width: 100%;
}

.input-group {
    position: relative;
    width: 100%;
    max-width: 420px;
}

.input-group .text-input {
    padding-right: 50px;
}

.resend-row {
    margin-top: 14px;
    width: 100%;
    max-width: 420px;
    text-align: right;
}

.text-link {
    background: none;
    border: none;
    color: var(--login-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.input-group .toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-container .code-inputs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.code-inputs input {
    width: 56px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    border: 1px solid #e2e8f0;
    background: #fff;
    outline: none;
    border-radius: 10px;
    padding: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
    caret-color: var(--login-primary);
}

.code-inputs input:hover {
    border-color: #cbd5e0;
}

.code-inputs input:focus {
    border-color: var(--login-primary);
    box-shadow: 0 0 0 3px var(--login-primary-shadow);
}

.code-inputs input.filled {
    border-color: var(--login-primary);
    background: #f7fafc;
}

.code-inputs input.error-cell {
    border-color: #e53e3e;
    animation: shake 0.35s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.method-btn {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 12px;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #1e293b;
}

.method-btn:hover {
    border-color: var(--login-primary);
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.method-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.method-detail {
    color: #64748b;
    font-size: 0.9rem;
}

/* Modal 2FA profesional */
.modal-no-code {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content-no-code {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 40px 240px rgba(0, 0, 0, 0.66);
    width: 95vw;
    position: relative;
    text-align: center;
}

.close-modal-no-code {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
}

.modal-content-no-code h4 {
    margin-top: 0;
    font-weight: 600;
    color: var(--login-primary);
    margin-bottom: 10px;
}

.modal-desc {
    color: #444;
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1.1rem;
}

.btn-modal {
    background: var(--login-primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s;
}

.btn-modal:disabled {
    background: #b3c2e6;
    cursor: not-allowed;
}

.btn-modal-alt {
    background: #fff;
    color: var(--login-primary);
    border: 1px solid var(--login-primary);
    border-radius: 5px;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}

.btn-modal-alt:hover:not(:disabled) {
    background: #f2f6ff;
}

.btn-modal-alt:disabled {
    border-color: #cbd5e0;
    color: #cbd5e0;
    cursor: not-allowed;
}

.modal-timer-row {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 0.7rem;
}

.modal-msg {
    font-size: 0.9rem;
    min-height: 1.2em;
    margin-top: 0.5em;
}

/* Timer principal */
.timer-row {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    font-size: 0.85rem;
    color: #a0aec0;
    margin-top: 10px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 420px;
}

#timer {
    font-weight: 600;
    color: var(--login-primary);
}

#timer.expired {
    color: #e53e3e;
}

/* Selección de método */
.methods-selection {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.method-selection-btn {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.method-selection-btn:hover:not(:disabled) {
    border-color: var(--login-primary);
    background: #f7fafc;
    transform: translateY(-1px);
}

.method-selection-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.method-info {
    display: flex;
    flex-direction: column;
}

.method-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a202c;
}

.method-val {
    font-size: 0.85rem;
    color: #718096;
}

.no-methods-notice {
    padding: 12px;
    background-color: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
    font-size: 0.85rem;
    text-align: center;
}


/* --- Responsive --- */
@media (max-width: 480px) {
    .tfa-card {
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
    }

    .tfa-card-header {
        padding: 24px 24px 20px;
    }

    .tfa-card-body {
        padding: 24px 24px 28px;
    }

    .code-inputs input {
        width: 48px;
        height: 52px;
        font-size: 1.3rem;
    }

    .code-inputs {
        gap: 8px;
    }
}

/* ---------------------------------------------------------------------------
   Medidor y checklist de contrasena
   Copia visual del que ya tiene el alta de usuarios
   (pages/usuarios/css/estilosUsuarios.css:729). Las reglas que se comprueban
   son las mismas -- clave_es_segura() en este archivo y password_es_segura()
   en pages/usuarios/request/request.php --, pero hasta ahora aqui no se veian:
   el usuario escribia a ciegas y solo se enteraba al enviar. Los colores van
   literales en vez de por variable porque esta hoja no define la paleta de
   --success/--border/--text-muted de aquel modulo; son los mismos valores.
   --------------------------------------------------------------------------- */
.pwd-strength-wrap {
    margin-top: 8px;
}

.pwd-strength {
    height: 4px;
    border-radius: 999px;
    background: #e0e0e0;
    overflow: hidden;
}

.pwd-strength-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: #e0e0e0;
    transition: width .2s ease, background-color .2s ease;
}

.pwd-strength-fill.debil {
    width: 33%;
    background: #c0392b;
}

.pwd-strength-fill.media {
    width: 66%;
    background: #d4a017;
}

.pwd-strength-fill.fuerte {
    width: 100%;
    background: #1d9a56;
}

.pwd-checklist {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 10px;
}

.pwd-checklist li {
    font-size: 11px;
    color: #999999;
    padding-left: 15px;
    position: relative;
}

.pwd-checklist li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid #e0e0e0;
}

.pwd-checklist li.ok {
    color: #1d9a56;
    font-weight: 600;
}

.pwd-checklist li.ok::before {
    border-color: #1d9a56;
    background: #1d9a56;
}

/* Aviso de que las dos contrasenas no coinciden. */
.pwd-aviso {
    display: none;
    margin-top: 6px;
    font-size: 11px;
    color: #c0392b;
}

.pwd-aviso.visible {
    display: block;
}
