/*
 * Two-Factor Authentication Styles
 */

.tfa-container {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.tfa-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 44px 40px 36px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    transition: opacity 0.3s, transform 0.3s;

    h1 {
        font-size: 21px;
        font-weight: 600;
        margin: 18px 0 6px;
        color: var(--text_color);
    }

    > p {
        color: #6b7280;
        margin-bottom: 28px;
        font-size: 13.5px;
        line-height: 1.6;
    }

    &.tfa-verifying {
        opacity: 0.6;
        pointer-events: none;
        transform: scale(0.98);
    }
}

.tfa-setup-card {
    max-width: 780px;
    text-align: center;

    > h1 {
        text-align: center;
        margin-bottom: 20px;
    }
}

.tfa-icon {
    text-align: center;

    .fa {
        font-size: 36px;
        color: @primary_color;
        background: fade(@primary_color, 8%);
        width: 72px;
        height: 72px;
        line-height: 72px;
        border-radius: 50%;
        display: inline-block;
    }
}

/* ---- Digit input boxes ---- */
.tfa-digits {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 0 auto 24px;
}

.tfa-digit {
    float: none !important;
    display: inline-block !important;
    width: 48px !important;
    height: 56px;
    text-align: center !important;
    font-size: 24px !important;
    font-weight: 600;
    font-family: 'Courier New', Courier, monospace;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    color: var(--text_color);
    padding: 0 !important;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
    caret-color: @primary_color;

    &:focus {
        border-color: @primary_color;
        background: #fff;
        outline: none;
        box-shadow: 0 0 0 3px fade(@primary_color, 12%);
        transform: translateY(-1px);
    }

    &.has-value {
        border-color: darken(@primary_color, 5%);
        background: #fff;
    }
}

.tfa-digit-separator {
    width: 12px;
    height: 3px;
    background: #d1d5db;
    border-radius: 2px;
    flex-shrink: 0;
    margin: 0 2px;
}

/* ---- Submit button ---- */
.tfa-submit {
    display: block !important;
    float: none !important;
    background: #d1d5db !important;
    color: #fff !important;
    border: none;
    padding: 13px 32px !important;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.25s, transform 0.15s, box-shadow 0.25s;
    width: 100%;
    max-width: 320px;
    margin: 8px auto 0;
    letter-spacing: 0.3px;
    pointer-events: none;

    &.tfa-submit-ready {
        background: @primary_color;
        pointer-events: auto;
        box-shadow: 0 2px 8px fade(@primary_color, 25%);

        &:hover {
            background: darken(@primary_color, 8%);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px fade(@primary_color, 30%);
        }

        &:active {
            transform: translateY(0);
            box-shadow: 0 1px 4px fade(@primary_color, 20%);
        }
    }
}

.tfa-help {
    color: #9ca3af;
    font-size: 12px;
    margin-top: 24px;

    .fa {
        margin-right: 4px;
    }
}

/* ---- Setup page layout ---- */
.tfa-setup-top {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    text-align: left;
    clear: both;
}

.tfa-setup-qr {
    flex-shrink: 0;
    text-align: center;
}

.tfa-setup-instructions {
    flex: 1;
    min-width: 0;
    padding: 8px 0 0 20px;
    margin: 0;
    list-style: none;
    counter-reset: tfa-steps;

    li {
        counter-increment: tfa-steps;
        position: relative;
        padding-left: 32px;
        margin-bottom: 14px;
        font-size: 13.5px;
        color: #374151;
        line-height: 1.6;

        &:last-child {
            margin-bottom: 0;
        }

        &::before {
            content: counter(tfa-steps);
            position: absolute;
            left: 0;
            top: 0;
            width: 22px;
            height: 22px;
            line-height: 22px;
            text-align: center;
            background: @primary_color;
            color: #fff;
            border-radius: 50%;
            font-weight: 600;
            font-size: 12px;
        }
    }
}

.tfa-setup-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 24px 0;
    clear: both;
}

.tfa-setup-confirm {
    text-align: center;
    clear: both;

    .tfa-submit {
        margin: 8px auto 0;
    }
}

/* ---- QR code ---- */
.tfa-qr-wrapper {
    text-align: center;
    margin: 0 0 8px;
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    display: inline-block;

    svg {
        display: block;
        max-width: 160px;
        height: auto;
    }
}

/* Manual key */
.tfa-manual-key {
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;

    span {
        display: block;
        margin-bottom: 4px;
    }
}

.tfa-secret-display {
    display: inline-block;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    letter-spacing: 1px;
    color: #374151;
    user-select: all;
    word-break: break-all;
}

/* ---- 2FA status badge on manage page ---- */
.tfa-badge {
    display: inline-block;
    font-size: 16px;
    cursor: default;
    position: static;

    i {
        position: static !important;
        float: none !important;
        display: inline !important;
        font-size: inherit !important;
        line-height: inherit;
    }

    &.tfa-badge-active {
        color: @success_color;
    }

    &.tfa-badge-pending {
        color: @med_color;
    }
}

/* ---- Sudo re-auth on edit page ---- */
.tfa-sudo-container {
    padding: 20px 0;
    float: none;
    clear: both;
    overflow: visible;

    .tfa-card {
        max-width: 400px;
        float: none;
        overflow: visible;
    }

    .tfa-digits {
        float: none !important;
        clear: both;
        overflow: visible;
    }

    form {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        float: none !important;
        width: auto !important;
    }
}

/* ---- Reset 2FA section on edit page ---- */
.tfa-reset-section {
    padding: 16px 0;
    float: left;
    width: 100%;
    clear: both;

    .tfa-status {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
        float: left;
        width: 100%;

        .fa {
            font-size: 16px;
            position: static !important;
            float: none !important;
            display: inline !important;
            font-size: 16px !important;
        }

        .fa-check-circle {
            color: @msg_success_bg;
        }

        .fa-times-circle {
            color: @msg_alert_bg;
        }
    }

    form {
        float: left;
        width: 100%;
        clear: both;
    }

    .btn {
        float: left;
    }
}

/* ---- Responsive ---- */
@media (max-width: @mobile) {
    .tfa-card {
        padding: 28px 20px 24px;
    }

    .tfa-setup-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .tfa-setup-instructions {
        padding-top: 0;
        padding-left: 0;
    }

    .tfa-digit {
        width: 40px !important;
        height: 48px;
        font-size: 20px !important;
    }

    .tfa-digits {
        gap: 6px;
    }
}
