/* auth.css - 授权登录与用户信息样式 */

.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    /* Higher than top-nav (2000) */
    display: none;
    /* Hidden by default to prevent blocking clicks */
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.auth-modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s forwards;
}

.ml-card {
    background: #fff;
    width: 340px;
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: center;
    transform: scale(0.95);
    animation: zoomIn 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes zoomIn {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.ml-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

.ml-header {
    margin-bottom: 32px;
}

.ml-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.ml-input-group {
    display: flex;
    align-items: center;
    height: 48px;
    background: #f7f7f7;
    border-radius: 24px;
    padding: 0 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.ml-input-group:focus-within {
    background: #fff;
    border-color: #ff2442;
    box-shadow: 0 0 0 3px rgba(255, 36, 66, 0.1);
}

.ml-prefix {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid #ddd;
    height: 20px;
    display: flex;
    align-items: center;
}

.ml-input {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 15px;
    color: #333;
    outline: none;
}

.ml-btn-code {
    border: none;
    background: none;
    color: #ff2442;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.ml-btn-submit {
    width: 100%;
    height: 48px;
    background: linear-gradient(90deg, #ff2442 0%, #ff4d6a 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    margin-top: 24px;
    box-shadow: 0 4px 12px rgba(255, 36, 66, 0.3);
    transition: all 0.2s;
}

.ml-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 36, 66, 0.4);
}

.ml-btn-submit:active {
    transform: translateY(0);
}

.ml-agreement {
    margin-top: 16px;
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    /* Center vertically */
    justify-content: center;
    /* Center horizontally */
    gap: 8px;
    /* Consistent gap */
    width: 100%;
}

.ml-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #ff2442;
    cursor: pointer;
    flex-shrink: 0;
}

.ml-footer-hint {
    margin-top: 24px;
    font-size: 12px;
    color: #999;
    text-align: center;
    line-height: 1.5;
}

/* User Profile Top Bar */
.user-profile-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 30px;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.user-name {
    font-size: 0.8rem;
    color: #374151;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* QR Popup Dropdown (Absolute to container) */
.qr-popup-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    /* Directly below button with gap */
    left: 50%;
    transform: translateX(-50%);
    /* Center horizontal */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    /* Ensure top-most layer */
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: popupFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 240px;
}

.qr-popup-dropdown .qr-img {
    width: 180px;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: #fff;
    padding: 8px;
    border: 1px solid #f3f4f6;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@media (max-width: 800px) {
    .qr-popup-dropdown {
        width: 180px;
        /* No longer need absolute right/top overrides as we use 100% and translateX */
    }
}

/* =========================================
   Captcha Modal Styles
   ========================================= */

.captcha-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.captcha-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.captcha-card {
    background: #fff;
    width: 312px;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.captcha-modal-overlay.active .captcha-card {
    transform: scale(1);
}

.captcha-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.captcha-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.captcha-canvas-container {
    position: relative;
    width: 280px;
    height: 155px;
    margin: 0 auto 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}

#captcha-bg,
#captcha-puzzle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#captcha-puzzle {
    z-index: 2;
}

.captcha-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #999;
    z-index: 1;
}

/* Slider */
.captcha-slider-container {
    position: relative;
    width: 280px;
    height: 40px;
    background: #f7f9fa;
    border: 1px solid #e4e7eb;
    border-radius: 20px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    margin: 0 auto 12px;
    user-select: none;
}

.captcha-track {
    position: absolute;
    width: 100%;
    height: 100%;
}

.captcha-track-mask {
    position: absolute;
    top: 0;
    left: 0;
    height: 38px;
    width: 0;
    background: #e6f7ff;
    border-radius: 20px 0 0 20px;
    border: 1px solid #91d5ff;
    border-right: none;
    box-sizing: border-box;
}

.captcha-slider-btn {
    position: absolute;
    top: -1px;
    left: 0;
    width: 44px;
    height: 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    z-index: 5;
}

.captcha-slider-btn:hover {
    background: #1890ff;
    border-color: #1890ff;
}

.captcha-slider-btn:hover .captcha-arrow {
    color: #fff;
}

.captcha-arrow {
    font-size: 16px;
    color: #666;
    font-weight: 700;
}

.captcha-text {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #999;
    z-index: 1;
    pointer-events: none;
    /* Let clicks pass */
}

/* Feedback States */
.captcha-slider-btn.success {
    background: #52c41a;
    border-color: #52c41a;
    color: #fff;
}

.captcha-slider-btn.fail {
    background: #ff4d4f;
    border-color: #ff4d4f;
    color: #fff;
    animation: shake 0.4s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

.captcha-footer-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}

.captcha-refresh {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
}

.captcha-refresh:hover {
    color: #666;
    background: #f3f3f3;
}

/* Error Message Container */
.ml-error {
    color: #ff4d4f;
    font-size: 13px;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 12px;
    text-align: center;
    width: 100%;
    animation: fadeIn 0.2s;
}