/* ==========================================================================
   2FA Modal — shared across login and two-factor-authentication pages
   ========================================================================== */

/* Close button */
.credentials-popup-close-button {
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.72;
}

.credentials-popup-close-button:hover {
    transform: scale(1.08);
    opacity: 1;
}

.credentials-popup-close-button img {
    width: 75%;
    height: 75%;
    display: block;
}

.twofa-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* Login-page popup sizing & theming */
#twofa-popup {
    padding: 28px 28px 22px;
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(125, 217, 208, 0.14), transparent 28%),
        linear-gradient(180deg, rgba(68, 63, 59, 0.98) 0%, rgba(45, 41, 38, 0.98) 100%);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

/* ==========================================================================
   Typography
   ========================================================================== */
.twofa-title {
    margin: 0 0 8px;
    font-family: var(--_typography---font-styles--heading);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.02;
    letter-spacing: -0.04em;
    text-align: center;
    color: #ffffff;
}

.twofa-title--auth-setup {
    margin: 0 36px 18px 0;
    text-align: left;
    font-family: var(--_typography---font-styles--body);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--_primitives---colors--neutral-darker);
}

.twofa-prompt {
    margin: 0 0 14px;
    font-family: var(--_typography---font-styles--body);
    font-weight: 500;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
}

.twofa-subtext {
    margin: 0 0 14px;
    padding-right: 24px;
    font-family: var(--_typography---font-styles--body);
    font-weight: 400;
    font-size: 14px;
    line-height: 1.65;
    text-align: center;
    color: rgba(255, 255, 255, 0.68);
}

/* ==========================================================================
   Error / Status Banner
   ========================================================================== */
.twofa-error {
    margin: 0 0 14px;
    padding: 11px 13px;
    border-radius: 12px;
    font-family: var(--_typography---font-styles--body);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.twofa-error.is-error {
    background: rgba(255, 128, 150, 0.12);
    color: #ffd7df;
    border: 1px solid rgba(255, 128, 150, 0.18);
}

.twofa-error.is-neutral {
    background: color-mix(in srgb, var(--_primitives---colors--warning) 12%, transparent);
    color: var(--_primitives---colors--warning-light);
    border: 1px solid color-mix(in srgb, var(--_primitives---colors--warning) 22%, transparent);
}

.twofa-error.is-good {
    background: color-mix(in srgb, var(--_primitives---colors--primary) 12%, transparent);
    color: var(--_primitives---colors--primary-light);
    border: 1px solid color-mix(in srgb, var(--_primitives---colors--primary) 20%, transparent);
}

/* ==========================================================================
   Code Input Boxes
   ========================================================================== */
.twofa-code-boxes {
    width: 100%;
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.twofa-code-boxes--setup {
    justify-content: flex-start;
    margin-top: 0;
}

.twofa-digit {
    box-sizing: border-box;
    width: 48px;
    height: 58px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--_primitives---colors--white);
    font-family: var(--_typography---font-styles--body);
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    outline: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.twofa-digit:focus {
    border-color: var(--_primitives---colors--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--_primitives---colors--primary) 16%, transparent);
}

.twofa-digit--setup {
    background: var(--_primitives---colors--white);
    border-color: var(--_primitives---colors--neutral-lighter);
    color: var(--_primitives---colors--neutral-darker);
}

/* ==========================================================================
   Modal Modes & Animations
   ========================================================================== */
.twofa-mode {
    display: none;
    animation: twofaModeIn 0.22s ease;
}

.twofa-mode.is-active {
    display: block;
}

@keyframes twofaModeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Method chooser */
.twofa-chooser-card {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.025) 100%);
}

.twofa-chooser-title {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}

.twofa-chooser-copy {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.68);
}

.twofa-method-list {
    display: grid;
    gap: 10px;
}

.twofa-method-btn {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 14px 15px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #f4f7fb;
    cursor: pointer;
    text-align: left;
    line-height: normal;
    white-space: normal;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.twofa-method-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(125, 217, 208, 0.3);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

.twofa-method-btn::after {
    content: "\203A";
    font-size: 18px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.twofa-method-btn > span {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.twofa-method-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #ffffff;
}

.twofa-method-hint {
    display: block;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.62);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

/* Recovery email sent card */
.twofa-recovery-popup {
    display: none;
    animation: twofaModeIn 0.22s ease;
}

.twofa-recovery-popup.is-visible {
    display: block;
}

.twofa-recovery-popup-card {
    width: min(100%, 348px);
    margin: 0 auto;
    padding: 18px 18px 16px;
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(125, 217, 208, 0.14), transparent 34%),
        linear-gradient(180deg, rgba(59, 54, 50, 0.98) 0%, rgba(35, 32, 30, 0.98) 100%);
    border: 1px solid rgba(125, 217, 208, 0.18);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
    text-align: left;
}

.twofa-recovery-popup-kicker {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(125, 217, 208, 0.1);
    border: 1px solid rgba(125, 217, 208, 0.18);
    color: #b9f2ec;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.twofa-recovery-popup-title {
    margin: 0 0 7px;
    font-size: 20px;
    line-height: 1.08;
    letter-spacing: -0.04em;
    color: #ffffff;
}

.twofa-recovery-popup-copy {
    font-size: 12px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.74);
}

.twofa-recovery-popup-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.twofa-recovery-popup-link {
    padding: 0;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.twofa-recovery-popup-link[disabled] {
    color: rgba(255, 255, 255, 0.4);
    cursor: default;
    text-decoration: none;
}

/* Recovery code input */
.twofa-recovery-section {
    text-align: left;
}

.twofa-recovery-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.01em;
}

.twofa-recovery-input {
    width: min(100%, 260px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.twofa-recovery-input:focus {
    outline: none;
    border-color: rgba(125, 217, 208, 0.45);
    box-shadow: 0 0 0 4px rgba(125, 217, 208, 0.14);
}

.twofa-recovery-toggle {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 12px 13px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.twofa-toggle-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.4;
}

.twofa-toggle-hint {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.52);
    line-height: 1.5;
}

#twofa-disable-authenticator {
    appearance: none;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border-radius: 6px;
    border: 1.5px solid var(--_primitives---colors--primary);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background 0.18s ease, border-color 0.18s ease;
}

#twofa-disable-authenticator:checked {
    background: var(--_primitives---colors--primary-darker);
    border-color: var(--_primitives---colors--primary-darker);
}

#twofa-disable-authenticator:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

#twofa-disable-authenticator:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--_primitives---colors--primary) 30%, transparent);
}

/* ==========================================================================
   Actions & Buttons
   ========================================================================== */
.twofa-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.twofa-btn {
    position: relative;
    width: 100%;
    min-height: 48px;
    padding: 14px 20px;
    background: var(--_primitives---colors--primary-darker);
    color: var(--_primitives---colors--primary-light);
    font-family: var(--_typography---font-styles--body);
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    border: 1px solid var(--_primitives---colors--primary-darker);
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    appearance: none;
    outline: none;
}

.twofa-btn:hover {
    background: var(--_primitives---colors--primary-darkest);
    border-color: var(--_primitives---colors--primary-darkest);
    transform: translateY(-1px);
}

.twofa-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.twofa-btn-secondary {
    min-height: 40px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.88);
}

.twofa-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--_primitives---colors--white);
}

.btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.78);
    border-radius: 50%;
    margin-left: 10px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.twofa-resend-hint {
    margin-top: 2px;
    font-family: var(--_typography---font-styles--body);
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
    color: rgba(255, 255, 255, 0.58);
}

/* Bottom container: groups alt-actions + footer */
.twofa-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.twofa-bottom::before {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.twofa-alt-trigger,
.twofa-back-link {
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    line-height: 28px;
    text-decoration: none;
    transition: color 0.2s ease;
    font-family: var(--_typography---font-styles--body);
}

.twofa-alt-trigger:hover,
.twofa-back-link:hover {
    background: transparent;
    color: var(--_primitives---colors--white);
}

.twofa-back-link {
    display: none;
    color: rgba(255, 255, 255, 0.62);
    font-weight: 500;
}

.twofa-back-link:hover {
    color: var(--_primitives---colors--white);
}

.twofa-alt-note {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
    text-align: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.twofa-footer {
    text-align: center;
}

.twofa-cancel-link {
    font-family: var(--_typography---font-styles--body);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.6;
    color: var(--_primitives---colors--primary);
    text-decoration: none;
}

.twofa-cancel-link:hover {
    color: var(--_primitives---colors--primary-light);
}

/* ==========================================================================
   Setup-flow modal overrides
   ========================================================================== */
.popup-message--auth-setup-flow {
    width: min(92vw, 520px);
    max-width: 520px;
    padding: 24px 24px 20px;
    background: linear-gradient(180deg, var(--_primitives---colors--primary-lightest), var(--_primitives---colors--white));
    border: 1px solid rgba(166, 213, 197, 0.45);
    z-index: 21600;
}

.popup-message--auth-setup-flow .twofa-close-btn {
    top: 18px;
    right: 18px;
}

.popup-message--auth-setup-flow .twofa-error {
    text-align: left;
    color: #b63f52;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media screen and (max-width: 576px) {
    .popup-message--auth-setup-flow {
        padding: 20px 16px 18px;
    }

    .twofa-title--auth-setup {
        margin-right: 36px;
        margin-bottom: 24px;
        font-size: 28px;
    }

    .twofa-digit {
        height: 52px;
        width: 40px;
        font-size: 19px;
        border-radius: 12px;
    }

    .twofa-code-boxes {
        gap: 8px;
    }

    .twofa-code-boxes--setup {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media screen and (max-width: 375px) {
    .twofa-digit {
        height: 48px;
        width: 36px;
        font-size: 18px;
        border-radius: 10px;
    }

    .twofa-code-boxes {
        gap: 7px;
    }
}

@media (max-width: 360px) {
    .twofa-code-boxes {
        gap: 6px;
    }

    .twofa-digit {
        width: 34px;
        height: 46px;
        font-size: 17px;
    }
}
