/* ============================================================
 * ReportServer 管理后台样式
 * 由 admin.html 内联样式拆分而来，负责页面的全部视觉呈现。
 * 结构：
 *   1. 设计变量与基础重置
 *   2. 顶部栏与统计指标
 *   3. 布局容器
 *   4. 标签页
 *   5. 筛选卡片与表单控件
 *   6. 按钮
 *   7. 表格与列表
 *   8. 分页控件
 *   9. 详情弹窗
 *  10. 加载态与错误提示
 *  11. 登录层
 *  12. 配置管理（微信/抖音凭证、访问控制）
 * ============================================================ */

/* ── 1. 设计变量与基础重置 ────────────────────────────── */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ── 2. 顶部栏与统计指标 ─────────────────────────────── */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 { font-size: 22px; font-weight: 600; }
.header .subtitle { font-size: 13px; opacity: 0.8; margin-top: 2px; }

.stats { display: flex; gap: 24px; }
.stat-item { text-align: right; }
.stat-item .label { font-size: 12px; opacity: 0.8; }
.stat-item .value { font-size: 24px; font-weight: 700; }

/* ── 3. 布局容器 ─────────────────────────────────────── */
.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }

/* ── 4. 标签页 ───────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 22px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* 标签页面板：由 JS 切换 .active 控制显隐 */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── 5. 筛选卡片与表单控件 ───────────────────────────── */
.filter-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.filter-group input, .filter-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.filter-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ── 6. 按钮 ─────────────────────────────────────────── */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }

/* ── 7. 表格与列表 ───────────────────────────────────── */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.table-header h2 { font-size: 16px; font-weight: 600; }
.table-header .count { font-size: 13px; color: var(--text-secondary); }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
tbody tr { cursor: pointer; transition: background 0.15s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.event-badge {
    display: inline-block;
    padding: 2px 10px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.mono { font-family: "Consolas", "Courier New", monospace; font-size: 12px; }
.props-preview {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-secondary); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* ── 8. 分页控件 ─────────────────────────────────────── */
.pagination {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pagination-info { font-size: 13px; color: var(--text-secondary); }
.pagination-controls { display: flex; gap: 6px; align-items: center; }
.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { padding: 0 4px; color: #94a3b8; }

/* ── 9. 详情弹窗 ─────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 24px;
    cursor: pointer; color: var(--text-secondary); line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 120px; font-weight: 500; color: var(--text-secondary); font-size: 13px; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 13px; word-break: break-all; }
.detail-value pre {
    background: #f8fafc; padding: 12px; border-radius: 6px;
    overflow-x: auto; font-size: 12px; line-height: 1.5;
}

/* ── 10. 加载态与错误提示 ────────────────────────────── */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
    display: inline-block; width: 24px; height: 24px;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
    background: #fef2f2; color: var(--danger); padding: 12px 20px;
    border-radius: 6px; margin-bottom: 16px; font-size: 14px; display: none;
}
.error-banner.active { display: block; }
.error-banner.success { background: #f0fdf4; color: var(--success); }

/* ── 11. 登录层 ──────────────────────────────────────── */
#loginOverlay {
    position: fixed; inset: 0; z-index: 2000; display: none;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    align-items: center; justify-content: center;
}
.login-card {
    background: #fff; padding: 36px 32px; border-radius: 12px;
    width: 320px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center;
}
.login-card h2 { font-size: 18px; color: var(--text); margin-bottom: 20px; }
.login-card input {
    width: 100%; padding: 10px 12px; margin-bottom: 12px;
    border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
    transition: border-color 0.2s;
}
.login-card input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.login-card .btn { width: 100%; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 12px; }
.logout-btn {
    background: rgba(255, 255, 255, 0.15); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; margin-left: 16px;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* ── 12. 配置管理（微信/抖音凭证、访问控制） ───────────── */
.settings-card { margin-bottom: 20px; }
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.settings-header h2 { font-size: 16px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }
.source-tag {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
}
.settings-hint { font-size: 12px; color: var(--text-secondary); }
.table-card .settings-hint { margin: 12px 24px; }
.filter-card .settings-hint { margin-top: 12px; }

/* 配置表格：输入框直填，行不可点击 */
.config-table tbody tr { cursor: default; }
.config-table tbody tr:hover { background: transparent; }
.config-table input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.config-table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
