/* ==========================================================================
   1. 基础重置与全局排版
   ========================================================================== */
body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: #333; }
.admin-body { display: flex; height: 100vh; background-color: #f4f6f9; }
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #f0f2f5; }
.popup-body { padding: 20px; background: #fff; font-family: sans-serif; }

h2 { margin-top: 0; color: #2c3e50; font-weight: 500; margin-bottom: 20px; }

/* ==========================================================================
   2. 侧边栏与主区域布局 (Admin 专属)
   ========================================================================== */
.sidebar { width: 220px; background-color: #2c3e50; color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-title { padding: 20px; font-size: 18px; font-weight: bold; text-align: center; background-color: #1a252f; }
.sidebar a { padding: 15px 20px; color: #bdc3c7; text-decoration: none; border-bottom: 1px solid #34495e; transition: all 0.2s; }
.sidebar a:hover { background-color: #34495e; color: #fff; }
.sidebar a.active { background-color: #3498db; color: #fff; border-left: 4px solid #2980b9; }
.logout-link { color: #e74c3c !important; border-top: 2px solid #1a252f; margin-top: auto; }

.main-content { flex: 1; padding: 30px; overflow-y: auto; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 25px; margin-bottom: 20px; }

/* ==========================================================================
   3. 登录框
   ========================================================================== */
.login-box { background: white; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; width: 300px; }
.login-box input { width: 100%; padding: 10px; margin: 15px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.login-box button { width: 100%; padding: 10px; background: #409eff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }

/* ==========================================================================
   4. 表格与表单基础
   ========================================================================== */
table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 14px; 
    margin-top: 15px; 
    /* 核心修复：移动端允许横向滑动，防止撑爆页面 */
    display: block; 
    overflow-x: auto; 
    white-space: nowrap; 
    -webkit-overflow-scrolling: touch; 
}
th, td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
th { background-color: #f8f9fa; color: #666; font-weight: bold; }

input[type="text"], input[type="password"], input[type="number"], select { padding: 8px; border: 1px solid #ddd; border-radius: 4px; }

/* ==========================================================================
   5. 按钮系统
   ========================================================================== */
button { padding: 8px 15px; border-radius: 4px; cursor: pointer; border: none; font-size: 13px; transition: 0.2s; }
.btn-save { background: #67c23a; color: #fff; }
.btn-save:hover { background: #5daf34; }
.btn-del { background: #f56c6c; color: #fff; }
.btn-del:hover { background: #e06262; }
.btn-warn { background: #e6a23c; color: #fff; }
.btn-info { background: #409eff; color: #fff; text-decoration: none; display: inline-block; padding: 8px 15px; border-radius: 4px; font-size: 13px; border: none; cursor: pointer;}

/* ==========================================================================
   6. 业务模块特定样式 (精准还原)
   ========================================================================== */
/* 通用文本颜色与状态 */
.text-mute { color: #999; }
.text-orange { color: #e6a23c; }
.text-blue { color: #409eff; }
.text-red { color: #f56c6c; }
.status-ok { color: green; }
.status-err { color: red; }
.mono { font-family: monospace; }
.small { font-size: 12px; }

/* 宽度辅助 */
.w-100 { width: 100%; box-sizing: border-box; margin-top: 5px; }
.w-100-px { width: 100px; margin: 0 10px; }
.w-80-px { width: 80px; margin-right: 15px; }
.max-600 { max-width: 600px; }

/* 全局成功/警告提示条 */
.msg-success { color: green; background: #f0f9eb; padding: 10px; border-radius: 4px; border: 1px solid #e1f3d8; margin-bottom: 20px;}
.alert-warn { background-color: #fef0f0; color: #f56c6c; border: 1px solid #fde2e2; padding: 10px 15px; border-radius: 4px; font-size: 13px; font-weight: bold; margin-bottom: 20px; line-height: 1.5; }

/* 首页：三大入口方块 */
.home-grid { display: flex; gap: 20px; }
.home-link { flex: 1; padding: 30px; text-align: center; border-radius: 8px; text-decoration: none; border: 1px solid #eee; display: block; }
.home-link h3 { margin: 0; }
.link-blue { background: #ecf5ff; color: #409eff; border-color: #d9ecff; }
.link-orange { background: #fdf6ec; color: #e6a23c; border-color: #faecd8; }
.link-green { background: #f0f9eb; color: #67c23a; border-color: #e1f3d8; }

/* 核心配置：API 密码眼睛 */
.api-key-wrapper { position: relative; width: 100%; margin-top: 5px; }
.api-key-wrapper input { width: 100%; padding-right: 40px; box-sizing: border-box; }
#apiKeyEye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #909399; font-size: 16px; user-select: none; }

/* 用户管理：额度操作与搜索表单 */
.search-form { margin-bottom: 20px; display: flex; gap: 10px; align-items: center; }
.search-form input { width: 250px; margin: 0; }
.quota-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.quota-input { width: 45px; padding: 4px; font-size: 12px; text-align: center; }
.q-btn { padding: 4px 8px; font-size: 14px; font-weight: bold; color: white; border: none; border-radius: 3px; cursor: pointer; }
.q-btn.add { background: #67c23a; }
.q-btn.sub { background: #f56c6c; }
.inline-form { display: inline-block; margin: 0 5px; }

/* 卡密管理：生成与搜索 */
.card-gen-form { background: #fdf6ec; padding: 20px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #faecd8; display: flex; align-items: center; flex-wrap: wrap; }
.fw-bold { font-weight: bold; color: #e6a23c; margin-right: 15px; }
.card-search-form { margin-bottom: 20px; background: #f4f6f9; padding: 15px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.card-search-form input { margin: 0; width: 200px; }

/* 独立资产查看页面 (新窗口) */
.popup-header { display: flex; justify-content: space-between; border-bottom: 2px solid #409eff; padding-bottom: 10px; margin-bottom: 20px; align-items: center; }

/* ==========================================================================
   7. 弹窗系统 (Modal) - 卡密生成后弹出
   ========================================================================== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.modal-content { background: #fff; width: 400px; padding: 25px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); position: relative; }
.modal-title { margin-top: 0; color: #409eff; display: flex; align-items: center; gap: 8px; }
.modal-desc { font-size: 13px; color: #909399; margin-bottom: 10px; }
#codesTextarea { width: 100%; height: 250px; padding: 12px; border: 1px solid #dcdfe6; border-radius: 8px; font-family: monospace; font-size: 14px; background: #f8f9fa; box-sizing: border-box; resize: none; outline: none; }
.modal-footer { margin-top: 20px; display: flex; gap: 10px; }
.btn-copy { flex: 2; background: #67c23a; color: #fff; border: none; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 14px;}
.btn-close { flex: 1; background: #f4f4f5; color: #606266; border: 1px solid #dcdfe6; padding: 10px; border-radius: 6px; cursor: pointer; }

/* ==========================================================================
   8. 分页组件
   ========================================================================== */
.pagination-container { margin-top: 20px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.pagination-btns { display: flex; gap: 5px; }
.pagination-btns a { text-decoration: none; padding: 6px 12px; border-radius: 4px; }

/* ==========================================
   表格行悬浮高亮反馈
   ========================================================================== */
tbody tr { 
    transition: background-color 0.2s ease; 
}
tbody tr:hover { 
    background-color: #f5f7fa; /* 极浅的蓝灰色 */
}

/* ==========================================
   状态标签胶囊化 (覆盖原有的 status-ok / status-err)
   ========================================================================== */
.status-ok { 
    background-color: #f0f9eb; 
    color: #67c23a; 
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: bold; 
    display: inline-block; 
    border: 1px solid #e1f3d8;
}

.status-err { 
    background-color: #fef0f0; 
    color: #f56c6c; 
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: bold; 
    display: inline-block;
    border: 1px solid #fde2e2;
}

/* ==========================================
   后台首页导航卡片悬浮动效
   ========================================================================== */
.home-link { 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* 平滑的回弹曲线 */
}
.home-link:hover {
    transform: translateY(-5px); /* 向上浮动 5px */
    box-shadow: 0 10px 20px rgba(0,0,0,0.08); /* 底部出现柔和阴影 */
}

/* ==========================================
   全局滚动条美化 (针对 Webkit 浏览器)
   ========================================================================== */
::-webkit-scrollbar { 
    width: 8px; /* 垂直滚动条宽度 */
    height: 8px; /* 水平滚动条高度 */
}
::-webkit-scrollbar-track { 
    background: transparent; 
}
::-webkit-scrollbar-thumb { 
    background: #dcdfe6; 
    border-radius: 4px; /* 变圆润 */
}
::-webkit-scrollbar-thumb:hover { 
    background: #c0c4cc; /* 鼠标放上去时颜色加深 */
}

/* ==========================================
   输入框焦点光晕 (Input Focus Ring)
   ========================================================================== */
input, select, textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; /* 移除浏览器默认的丑陋黑框 */
    border-color: #409eff; /* 边框变蓝 */
    /* 核心：添加四周扩散的半透明淡蓝光晕 */
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.15); 
}

/* ==========================================
   按钮按压真实物理反馈
   ========================================================================== */
button:active, .btn-info:active, .home-link:active {
    transform: scale(0.96) translateY(1px); /* 点击时微微缩小并下沉 */
    transition: transform 0.1s ease; /* 按下瞬间触发，极速响应 */
}

/* ==========================================
   弹窗背景毛玻璃与丝滑弹出动画
   ========================================================================== */
/* 给半透明黑背景加上毛玻璃模糊效果 */
.modal-overlay, #mailModal, #topupModal {
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px); /* 兼容苹果内核 */
}

/* 弹窗主体的丝滑弹出动画 */
.modal-content, .topup-content {
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* ==========================================
   表格无数据时的优雅空状态
   ========================================================================== */
td[colspan] {
    text-align: center;
    padding: 40px 20px !important; /* 加大上下留白 */
    color: #909399;
    background: #fafbfc; /* 极淡的灰背景 */
    border: 1px dashed #e4e7ed; /* 虚线边框 */
    letter-spacing: 1px;
}