/* Auth Screen Styles - Enterprise Clean Design */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f172a;
    /* 统一深蓝色 */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 9999;
}

/* PC Split Layout Container */
.auth-split-wrapper {
    display: flex;
    width: 1000px;
    height: 640px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    position: relative;
    transition: all 0.5s ease;
    -webkit-backdrop-filter: blur(10px);
    /* Safari 兼容 */
    backdrop-filter: blur(10px);
}

/* Left Brand Section (PC Only) */
.auth-left-brand {
    flex: 1.2;
    background: linear-gradient(135deg, #2563eb 0%, #1e1b4b 100%) !important;
    /* 使用蓝紫色渐变并强制覆盖 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    position: relative;
    color: #fff;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* 添加微小的分割线 */
}

.auth-left-brand::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect fill="white" fill-opacity="0.03" x="0" y="0" width="100" height="100"/></svg>') repeat;
    opacity: 0.1;
}

.brand-quote {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.8;
    /* 行距加倍 */
    margin-bottom: 24px;
    letter-spacing: -1px;
}

.brand-desc {
    font-size: 1.1rem;
    opacity: 0.8;
    line-height: 2.2;
    /* 行距加倍 */
}

/* Right Form Section */
.auth-right-form {
    flex: 1;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: rgba(20, 20, 35, 0.4);
    /* 🔧 [键盘适配] 由 Android 注入 --keyboard-height 变量，确保输入框可见 */
    padding-bottom: 60px;
    /* 🔧 [键盘适配] 禁用过渡，防止 padding 变化时晃动 */
    transition: none;
}

/* Mobile Fallback and Auth Container Override */
.auth-container {
    background: none;
    backdrop-filter: none;
    border: none;
    padding: 0;
    width: 100%;
    max-width: none;
    box-shadow: none;
    margin: 0;
}

.auth-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari 隐藏滚动条，保持简洁 */
}

.auth-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.auth-logo ion-icon {
    font-size: 2.2rem;
    color: #fff;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}

.auth-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 32px;
}

.mobile-auth-logo {
    display: none;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 32px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: 10px;
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.auth-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.auth-tab.active {
    background: var(--primary-color);
    color: #fff;
}

/* Auth Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-group ion-icon {
    position: absolute;
    left: 16px;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.auth-input-group:focus-within ion-icon {
    color: var(--primary-color);
}

.auth-input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.auth-input:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.12);
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.auth-error {
    color: #ef4444;
    font-size: 0.85rem;
    min-height: 20px;
    text-align: left;
    margin: -8px 0 0 4px;
}

.auth-btn {
    width: 100%;
    padding: 16px 24px;
    margin-top: 8px;
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.auth-btn:hover {
    background: var(--primary-variant);
    transform: translateY(-1px);
}

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

.auth-btn ion-icon {
    font-size: 1.2rem;
}

.auth-hint {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auth-hint ion-icon {
    font-size: 1rem;
    opacity: 0.7;
}

/* Admin/Frontend Jump Links */
.auth-admin-link:hover,
.admin-frontend-link:hover {
    background: rgba(102, 126, 234, 0.15) !important;
    border-color: rgba(102, 126, 234, 0.5) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.auth-admin-link:active,
.admin-frontend-link:active {
    transform: translateY(0);
}


/* User Info Bar in Sidebar */
.user-info-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: calc(var(--safe-top) + var(--header-content-height));
    padding: var(--safe-top) 12px 4px 12px;
    box-sizing: border-box;
    /* 🎨 [关键修复] 设置不透明背景与毛玻璃，封堵向上偏移的列表 */
    background: var(--surface-color) !important;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    z-index: 60;
    /* 🔑 高于列表项 (50) */
}

.user-avatar-small {
    /* 🔧 [对齐] 高度统一为 40px，与 chat-header 按钮一致 */
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-small ion-icon {
    font-size: 1.4rem;
    color: #fff;
}

.user-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 🔑 [紧凑布局] 紧凑行高 */
    line-height: 1.3;
}

/* 🔑 [紧凑布局] 用户信息容器（用户名+种族）限制高度 */
.user-info-bar>div:not(.user-avatar-small):not(button) {
    max-height: var(--header-content-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
}

.user-info-bar #current-user-species {
    font-size: 0.65rem;
    line-height: 1.2;
}

.btn-logout {
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    /* 🔧 [对齐] 高度统一为 40px，与 chat-header 按钮一致 */
    width: 40px;
    height: 40px;
    /* 🔧 [圆形边框] */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
}

.btn-logout ion-icon {
    /* 🔑 [统一图标] 与其他按钮图标大小一致 */
    font-size: 1.2rem;
}

@media (max-width: 1100px) {

    /* 全局禁止横向滚动 */
    html,
    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .auth-split-wrapper {
        width: 100%;
        width: 100vw;
        max-width: 100vw;
        /* 新增：强制限制最大宽度 */
        height: 100%;
        height: 100vh;
        height: 100dvh;
        /* 针对移动端浏览器动态视口高度 */
        border-radius: 0;
        border: none;
        flex-direction: column;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
        overflow-x: hidden;
        /* 新增 */
    }

    .auth-left-brand {
        display: none !important;
    }

    .auth-right-form {
        /* 🔑 [安全区域修复] 增加顶部内边距避开状态栏 */
        padding: calc(var(--safe-top) + 20px) 20px 40px;
        background: transparent;
        overflow-y: auto;
        overflow-x: hidden;
        /* 新增：明确禁止横向滚动 */
        -webkit-overflow-scrolling: touch;
        /* iOS 丝滑滚动 */
        width: 100%;
        max-width: 100vw;
        /* 新增：强制限制最大宽度 */
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        box-sizing: border-box;
        /* 新增：确保padding计算在内 */
    }

    .auth-header {
        text-align: center;
        /* 确保标题文字居中 */
        width: 100%;
        max-width: 100%;
        /* 新增 */
    }

    .auth-container {
        width: 100%;
        max-width: 360px;
        /* 适当缩小以适应手机 */
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-sizing: border-box;
        /* 新增 */
        padding: 0 4px;
        /* 新增：轻微内边距避免边缘溢出 */
    }

    .auth-form {
        width: 100%;
        max-width: 100%;
        /* 新增 */
        box-sizing: border-box;
        /* 新增 */
    }

    /* 确保所有输入元素不超宽 */
    .auth-input-group,
    .auth-input,
    .auth-btn,
    .auth-gender-picker,
    .captcha-slider-container {
        width: 100%;
        max-width: 100%;
        /* 新增 */
        box-sizing: border-box;
        /* 新增 */
    }

    .auth-screen {
        overflow-x: hidden;
        /* 禁止左右滑动 */
        overflow-y: auto;
        width: 100%;
        max-width: 100vw;
        /* 新增 */
    }

    .mobile-auth-logo {
        display: none !important;
    }

    .auth-input {
        background: rgba(255, 255, 255, 0.12);
        -webkit-appearance: none;
        appearance: none;
        /* 标准属性实现兼容 */
        border-radius: 12px;
        /* 增强移动端透明背景的可见度 */
    }
}

/* Custom Scrollbar for Form */
.auth-right-form::-webkit-scrollbar {
    width: 6px;
}

.auth-right-form::-webkit-scrollbar-track {
    background: transparent;
}

.auth-right-form::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Auth Title Adjustments */
.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.auth-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    opacity: 0.7;
}

/* Light Theme Overrides */
body.light-theme .auth-screen {
    background: linear-gradient(160deg, #f5f5f8 0%, #e8e8ec 100%);
}

body.light-theme .auth-container {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

body.light-theme .auth-tabs {
    background: rgba(0, 0, 0, 0.04);
}

body.light-theme .auth-tab:hover {
    background: rgba(0, 0, 0, 0.04);
}

body.light-theme .auth-input {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .auth-input:focus {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .user-info-bar {
    background: rgba(0, 0, 0, 0.02);
}

/* Slider Captcha Styles */
.captcha-slider-container {
    position: relative;
    width: 100%;
    height: 48px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    margin-bottom: 8px;
}

.captcha-slider-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1;
}

.captcha-slider-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0.3;
    z-index: 2;
}

.captcha-slider-thumb {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 100%;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 3;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

.captcha-slider-thumb:active {
    cursor: grabbing;
}

.captcha-slider-thumb ion-icon {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.captcha-slider-container.success {
    border-color: #10b981;
}

.captcha-slider-container.success .captcha-slider-bar {
    width: 100% !important;
    background: #10b981;
    opacity: 0.2;
}

.captcha-slider-container.success .captcha-slider-thumb {
    background: #10b981 !important;
    left: calc(100% - 50px) !important;
    cursor: default;
}

.captcha-slider-container.success .captcha-slider-thumb ion-icon {
    color: #fff;
}

.captcha-slider-container.success .captcha-slider-bg {
    color: #10b981;
    content: '验证通过';
}

/* Upgraded Gender Picker */
.auth-gender-picker {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.gender-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 8px;
}

.gender-option ion-icon {
    font-size: 1.6rem;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.gender-option span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.gender-option:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

/* Male Active State */
.gender-option[data-gender="male"].active {
    background: rgba(102, 126, 234, 0.15);
    border-color: #667eea;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.gender-option[data-gender="male"].active ion-icon,
.gender-option[data-gender="male"].active span {
    color: #667eea;
}

/* Female Active State */
.gender-option[data-gender="female"].active {
    background: rgba(236, 72, 153, 0.15);
    border-color: #ec4899;
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.2);
}

.gender-option[data-gender="female"].active ion-icon,
.gender-option[data-gender="female"].active span {
    color: #ec4899;
}

.gender-option:active {
    transform: scale(0.95);
}

/* Auth Select Styles */
.auth-select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}

/* User Profile Gender Pills */
.gender-pill-label {
    cursor: pointer;
}

.gender-pill {
    display: inline-block;
    padding: 6px 20px;
    background: var(--surface-light);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.gender-pill-label input:checked+.gender-pill {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Light Theme Adjustments */
body.light-theme .captcha-slider-container {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .captcha-slider-bg {
    color: rgba(0, 0, 0, 0.4);
}

body.light-theme .auth-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .auth-container {
        margin: 16px;
        padding: 32px 24px;
        border-radius: 16px;
    }

    .auth-title {
        font-size: 1.4rem;
    }

    .auth-logo {
        width: 60px;
        height: 60px;
        border-radius: 14px;
    }

    .auth-logo ion-icon {
        font-size: 1.8rem;
    }
}