/* ============================================
   超级管理后台 - 公共样式
   ============================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f1f5f9;
    --white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --radius: 8px;
}

body.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

.admin-wrapper { display: flex; flex-direction: column; min-height: 100vh; }

/* ============ 顶部导航 ============ */
.admin-header {
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
    background: none; border: none; font-size: 20px; cursor: pointer;
    padding: 6px 10px; border-radius: 6px; display: none;
}
.menu-toggle:hover { background: var(--bg); }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
.logo-icon { font-size: 22px; }

.admin-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #e0e7ff; }
.user-avatar.default-avatar { display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 600; }
.user-name { font-weight: 500; }
.logout-btn { color: var(--danger); text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
.logout-btn:hover { background: #fee2e2; }

/* ============ 侧边栏 ============ */
.admin-sidebar {
    width: 220px;
    background: var(--white);
    border-right: 1px solid var(--border);
    position: fixed; top: 56px; left: 0; bottom: 0;
    overflow-y: auto;
    transition: transform .2s;
}
.sidebar-nav ul { list-style: none; padding: 12px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav li.active a {
    background: #eef2ff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ============ 主内容 ============ */
.admin-main { margin-left: 220px; padding: 24px; min-height: calc(100vh - 56px); }

/* ============ 卡片 ============ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============ 统计卡片 ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; display: flex; justify-content: space-between; align-items: center;
}
.stat-info .stat-label { color: var(--text-muted); font-size: 13px; }
.stat-info .stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-icon { font-size: 36px; opacity: .8; }

/* ============ 表格 ============ */
.table-wrapper { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th, table.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table .num-col { text-align: right; font-variant-numeric: tabular-nums; }

/* 平台图标+名称 */
.platform-cell { display: flex; align-items: center; gap: 8px; }
.platform-icon { width: 24px; height: 24px; border-radius: 4px; object-fit: contain; }
.account-cell { display: flex; align-items: center; gap: 10px; }
.account-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #e2e8f0; }
.account-info { line-height: 1.3; }
.account-nick { font-weight: 500; }
.account-username { color: var(--text-muted); font-size: 12px; }

/* 状态标签 */
.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
}
.status-online { background: #d1fae5; color: #065f46; }
.status-offline { background: #fee2e2; color: #991b1b; }
.status-disabled { background: #f1f5f9; color: #64748b; }
.status-active { background: #dbeafe; color: #1e40af; }
.status-expired { background: #fef3c7; color: #92400e; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text); }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
    background: var(--white);
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px;
    font-size: 14px; font-weight: 500;
    cursor: pointer; border: none; text-decoration: none;
    transition: all .15s;
    background: var(--bg); color: var(--text);
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-link { background: none; color: var(--primary); padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-group { display: flex; gap: 8px; }

/* ============ 警告提示 ============ */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ============ 工具类 ============ */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .search-form { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar .search-form input, .toolbar .search-form select { min-width: 160px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-20 { margin-bottom: 20px; }
.mr-10 { margin-right: 10px; }
.w-auto { width: auto !important; }

/* ============ 分页 ============ */
.pagination { margin-top: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.pagination-list { list-style: none; display: flex; gap: 4px; }
.pagination-list a, .pagination-list span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); text-decoration: none; font-size: 13px;
}
.pagination-list a:hover { border-color: var(--primary); color: var(--primary); }
.pagination-list li.active span { background: var(--primary); color: white; border-color: var(--primary); }
.pagination-info { color: var(--text-muted); font-size: 13px; }

/* ============ Modal ============ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal {
    background: var(--white); border-radius: var(--radius);
    width: 100%; max-width: 520px; box-shadow: var(--shadow-md);
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); text-align: right; display: flex; justify-content: flex-end; gap: 10px; }

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-card {
    background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md);
    padding: 40px; width: 100%; max-width: 400px;
}
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 22px; }
.login-card .login-sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.login-card .form-group { margin-bottom: 18px; }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .admin-sidebar { transform: translateX(-100%); z-index: 99; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ============ 自定义Checkbox ============ */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 24px; transition: .2s;
}
.slider::before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============ Tooltip ============ */
.ticket-code {
    display: inline-block; padding: 2px 8px;
    background: #f1f5f9; border-radius: 4px;
    font-family: monospace; font-size: 12px; color: var(--text-muted);
}
