/* ==================== 学生违纪人脸识别系统 - 管理后台样式 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif; background: #f0f2f5; color: #333; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%); color: #fff; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; overflow-y: auto; }
.main { margin-left: 240px; flex: 1; min-height: 100vh; }

/* 侧边栏 */
.sidebar-logo { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo h2 { font-size: 18px; font-weight: 600; }
.sidebar-logo p { font-size: 12px; opacity: 0.6; margin-top: 4px; }
.sidebar-nav { padding: 12px 0; }
.nav-item { display: flex; align-items: center; padding: 12px 20px; cursor: pointer; transition: all 0.2s; font-size: 14px; color: rgba(255,255,255,0.7); border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #4fc3f7; border-left-color: #4fc3f7; font-weight: 500; }
.nav-icon { margin-right: 10px; width: 24px; height: 24px; text-align: center; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg { display: block; }

/* 一级菜单（可展开） */
.nav-group { border-left: 3px solid transparent; }
.nav-group-title { display: flex; align-items: center; padding: 12px 20px; cursor: pointer; transition: all 0.2s; font-size: 14px; color: rgba(255,255,255,0.7); user-select: none; }
.nav-group-title:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-group.open { border-left-color: #4fc3f7; }
.nav-group.open > .nav-group-title { color: #4fc3f7; background: rgba(255,255,255,0.06); font-weight: 500; }
.nav-group-arrow { margin-left: auto; transition: transform 0.25s; font-size: 12px; opacity: 0.5; }
.nav-group.open > .nav-group-title .nav-group-arrow { transform: rotate(90deg); opacity: 0.8; }

/* 二级子菜单 */
.nav-sub { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; background: rgba(0,0,0,0.15); }
.nav-group.open > .nav-sub { max-height: 300px; }
.nav-sub .nav-item { padding: 10px 20px 10px 54px; font-size: 13px; border-left: none; }
.nav-sub .nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-sub .nav-item.active { color: #4fc3f7; background: rgba(79,195,247,0.1); border-left: none; font-weight: 500; }

/* 顶部栏 */
.header { background: #fff; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 4px rgba(0,0,0,0.08); position: sticky; top: 0; z-index: 50; }
.header h3 { font-size: 16px; color: #1a1a2e; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-right span { font-size: 13px; color: #666; }
.btn-logout { padding: 6px 16px; border: 1px solid #e0e0e0; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; color: #666; }
.btn-logout:hover { background: #f5f5f5; color: #e74c3c; border-color: #e74c3c; }

/* 用户下拉菜单 */
.user-dropdown { position: relative; }
.user-dropdown-toggle { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; color: #666; border: 1px solid #e0e0e0; background: #fff; transition: all 0.2s; }
.user-dropdown-toggle:hover { border-color: #4fc3f7; color: #4fc3f7; }
.user-dropdown-toggle .arrow { font-size: 10px; transition: transform 0.2s; }
.user-dropdown.open .user-dropdown-toggle .arrow { transform: rotate(180deg); }
.user-dropdown-menu { position: absolute; top: 100%; right: 0; margin-top: 6px; background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 140px; z-index: 200; display: none; overflow: hidden; }
.user-dropdown.open .user-dropdown-menu { display: block; }
.user-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; color: #333; cursor: pointer; transition: background 0.15s; }
.user-dropdown-item:hover { background: #f5f7fa; }
.user-dropdown-item.danger { color: #e74c3c; }
.user-dropdown-item.danger:hover { background: #fef0f0; }
.user-dropdown-divider { height: 1px; background: #f0f0f0; margin: 4px 0; }

/* 内容区 */
.content { padding: 24px; }
.page { display: none; }
.page.active { display: block; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.stat-card .label { font-size: 13px; color: #999; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-card .sub { font-size: 12px; color: #52c41a; margin-top: 4px; }

/* 表格 */
.table-card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.table-header h4 { font-size: 15px; font-weight: 600; }
.table-toolbar { display: flex; gap: 10px; align-items: center; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { background: #fafafa; padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 600; color: #666; border-bottom: 1px solid #f0f0f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th:has(input[type="checkbox"]) { overflow: visible; text-overflow: clip; padding: 12px 8px; }
td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #f5f5f5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
td:has(input[type="checkbox"]) { overflow: visible; text-overflow: clip; padding: 12px 8px; max-width: none; }
td[title] { cursor: default; }
tr:hover td { background: #fafafa; }

/* 按钮 */
.btn { padding: 7px 16px; border-radius: 4px; border: none; cursor: pointer; font-size: 13px; transition: all 0.2s; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background: #4fc3f7; color: #fff; }
.btn-primary:hover { background: #29b6f6; }
.btn-success { background: #66bb6a; color: #fff; }
.btn-success:hover { background: #43a047; }
.btn-danger { background: #ef5350; color: #fff; }
.btn-danger:hover { background: #e53935; }
.btn-default { background: #fff; color: #333; border: 1px solid #d9d9d9; }
.btn-default:hover { border-color: #4fc3f7; color: #4fc3f7; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 输入框 */
.input { height: 36px; padding: 0 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; outline: none; transition: border-color 0.2s; }
.input:focus { border-color: #4fc3f7; box-shadow: 0 0 0 2px rgba(79,195,247,0.1); }
.select { height: 36px; padding: 0 30px 0 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; outline: none; background: #fff; cursor: pointer; }
textarea.input { height: auto; padding: 8px 12px; resize: vertical; }

/* 弹窗 */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-content { background: #fff; border-radius: 8px; width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.modal-header { padding: 16px 24px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h4 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }
.modal-close:hover { color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #333; }
.form-group .input, .form-group .select { width: 100%; }

/* 可搜索下拉选择器 */
.searchable-select { position: relative; width: 100%; }
.searchable-select-input-wrap { position: relative; }
.searchable-select-input { width: 100%; padding-right: 28px !important; cursor: text; }
.searchable-select-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; color: #999; pointer-events: none; }
.searchable-select-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #d9d9d9; border-top: none; border-radius: 0 0 4px 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 260px; overflow-y: auto; z-index: 300; }
.searchable-select.open .searchable-select-dropdown { display: block; }
.searchable-select.open .searchable-select-input { border-color: #4fc3f7; box-shadow: 0 0 0 2px rgba(79,195,247,0.1); border-radius: 4px 4px 0 0; border-bottom-color: transparent; }
.searchable-select-item { padding: 8px 12px; font-size: 13px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid #f5f5f5; }
.searchable-select-item:hover { background: #e3f2fd; }
.searchable-select-item.selected { background: #e3f2fd; color: #1e88e5; font-weight: 500; }
.searchable-select-item .item-name { font-weight: 500; }
.searchable-select-item .item-info { font-size: 12px; color: #999; margin-left: 6px; }
.searchable-select-loading, .searchable-select-empty { padding: 12px; text-align: center; font-size: 13px; color: #999; }

/* 标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; }
.tag-success { background: #e8f5e9; color: #43a047; }
.tag-warning { background: #fff3e0; color: #ef6c00; }
.tag-danger { background: #ffebee; color: #e53935; }
.tag-info { background: #e3f2fd; color: #1e88e5; }
.tag-default { background: #f5f5f5; color: #999; }

/* 分页 */
.pagination { padding: 16px 20px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagination span { font-size: 13px; color: #666; margin-right: 4px; }
.pagination .page-ellipsis { padding: 4px 6px; font-size: 13px; color: #999; cursor: default; }

/* 提示 */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); padding: 10px 24px; border-radius: 4px; color: #fff; font-size: 14px; z-index: 300; display: none; }
.toast.success { background: #66bb6a; }
.toast.error { background: #ef5350; }
.toast.show { display: block; animation: fadeInDown 0.3s; }
@keyframes fadeInDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* 登录页面 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.login-card h2 { text-align: center; margin-bottom: 8px; color: #1a1a2e; }
.login-card p { text-align: center; color: #999; font-size: 13px; margin-bottom: 32px; }
.login-card .form-group { margin-bottom: 20px; }
.login-card .btn-primary { width: 100%; height: 42px; justify-content: center; font-size: 15px; }

/* 图表占位 */
.chart-placeholder { background: #fafafa; border: 2px dashed #e0e0e0; border-radius: 8px; padding: 40px; text-align: center; color: #999; margin: 16px 0; }
.empty-state { text-align: center; padding: 40px; color: #999; }

/* 仪表盘卡片 */
.dashboard-card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 20px; overflow: hidden; }
.dashboard-card-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.dashboard-card-header h4 { font-size: 15px; font-weight: 600; }
.dashboard-card-body { padding: 20px; }
.dashboard-row { display: flex; gap: 20px; }
.dashboard-card-half { flex: 1; min-width: 0; }

/* 排行列表 */
.rank-list { max-height: 320px; overflow-y: auto; }
.rank-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.rank-item:last-child { border-bottom: none; }
.rank-num { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 12px; flex-shrink: 0; background: #f0f0f0; color: #999; }
.rank-num.top1 { background: linear-gradient(135deg, #ffd700, #ffb300); color: #fff; }
.rank-num.top2 { background: linear-gradient(135deg, #c0c0c0, #9e9e9e); color: #fff; }
.rank-num.top3 { background: linear-gradient(135deg, #cd7f32, #a0522d); color: #fff; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 14px; font-weight: 500; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { font-size: 12px; color: #999; margin-top: 2px; }
.rank-count { font-size: 16px; font-weight: 700; color: #1a1a2e; flex-shrink: 0; margin-left: 12px; }
.rank-count span { font-size: 12px; font-weight: 400; color: #999; margin-left: 2px; }
.rank-bar-bg { height: 4px; background: #f0f0f0; border-radius: 2px; margin-top: 6px; }
.rank-bar { height: 100%; background: linear-gradient(90deg, #4fc3f7, #29b6f6); border-radius: 2px; transition: width 0.6s ease; }
.rank-empty { text-align: center; padding: 40px 0; color: #999; font-size: 14px; }

/* ==================== 移动端响应式 ==================== */
/* 侧边栏遮罩层 */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 99; }
.sidebar-overlay.active { display: block; }

/* 汉堡菜单按钮 */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: #333; }
.menu-toggle svg { display: block; }

@media (max-width: 900px) {
    .dashboard-row { flex-direction: column; }
}

@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { position: fixed; top: 0; left: -260px; width: 240px; height: 100vh; z-index: 100; transition: left 0.3s ease; }
    .sidebar.open { left: 0; }
    .main { margin-left: 0; width: 100%; }
    .menu-toggle { display: flex; align-items: center; }
    .header { padding: 0 12px; height: 52px; }
    .header h3 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
    .header-right { gap: 8px; flex-shrink: 0; }
    .header-right span { font-size: 12px; }
    .content { padding: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 22px; }
    .stat-card .label { font-size: 12px; }
    .stat-card-icon { width: 38px; height: 38px; font-size: 14px; margin-right: 10px; }
    .dashboard-card-header { padding: 12px 16px; }
    .dashboard-card-header h4 { font-size: 14px; }
    .dashboard-card-body { padding: 12px; }
    .table-header { flex-wrap: wrap; gap: 8px; padding: 12px; }
    .table-header h4 { font-size: 14px; width: 100%; }
    .table-toolbar { flex-wrap: wrap; gap: 6px; width: 100%; }
    .table-toolbar .input { width: 100% !important; max-width: none !important; }
    .table-toolbar .select { max-width: 100%; }
    .table-toolbar .btn { font-size: 12px; padding: 6px 10px; }
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-scroll table { min-width: 600px; }
    .pagination { padding: 10px 12px; justify-content: center; }
    .pagination span { font-size: 12px; }
    .modal-content { width: 95vw; max-height: 90vh; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 12px 16px; }
    .modal-footer { padding: 12px 16px; }
    .login-card { width: 90vw; padding: 28px 20px; }
    .login-card h2 { font-size: 18px; }
    .stats-filter-bar { padding: 12px; }
    .stats-filter-bar-inner { gap: 8px; }
    .stats-filter-bar-inner .input,
    .stats-filter-bar-inner .select { width: 100% !important; max-width: none !important; }
    .user-dropdown-toggle { padding: 4px 8px; font-size: 12px; }
    .user-dropdown-toggle .tag { display: none; }
    .user-dropdown-menu { right: -10px; min-width: 120px; }
    .toast { font-size: 13px; padding: 8px 16px; top: 12px; white-space: nowrap; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .content { padding: 8px; }
    .header h3 { max-width: 30vw; font-size: 13px; }
    .stat-card .value { font-size: 20px; }
    .stat-card-icon { width: 34px; height: 34px; font-size: 12px; }
    .btn { padding: 6px 10px; font-size: 12px; }
    .btn-sm { padding: 3px 8px; font-size: 11px; }
}

/* 统计页面增强 */
.stats-filter-bar { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 16px 20px; margin-bottom: 20px; }
.stats-filter-bar-inner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stat-card-blue { border-left: 4px solid #4fc3f7; }
.stat-card-orange { border-left: 4px solid #ff9800; }
.stat-card-green { border-left: 4px solid #66bb6a; }
.stat-card-purple { border-left: 4px solid #ab47bc; }
.stat-card-icon { margin-right: 16px; flex-shrink: 0; width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: bold; }
.stat-card-blue .stat-card-icon { background: #e3f2fd; color: #1565c0; }
.stat-card-green .stat-card-icon { background: #e8f5e9; color: #2e7d32; }
.stat-card-orange .stat-card-icon { background: #fff3e0; color: #ef6c00; }
.stat-card-purple .stat-card-icon { background: #f3e5f5; color: #7b1fa2; }
.stat-card-body { flex: 1; }
.stat-card { display: flex; align-items: center; }
.stats-detail-table { width: 100%; border-collapse: collapse; }
.stats-detail-table th { background: #fafafa; padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; color: #999; border-bottom: 1px solid #f0f0f0; }
.stats-detail-table td { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid #f5f5f5; }
.stats-detail-table tr:hover td { background: #fafafa; }
.stats-bar { height: 6px; background: #f0f0f0; border-radius: 3px; margin-top: 4px; }
.stats-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #4fc3f7, #29b6f6); transition: width 0.6s ease; }
.stats-bar-fill.orange { background: linear-gradient(90deg, #ff9800, #f57c00); }

/* API 调用进度条 */
.api-quota-bar-bg { height: 5px; background: #f0f0f0; border-radius: 3px; margin-top: 6px; }
.api-quota-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #4fc3f7, #29b6f6); transition: width 0.6s ease; }
.api-quota-bar-fill.warning { background: linear-gradient(90deg, #ff9800, #f57c00); }
.api-quota-bar-fill.danger  { background: linear-gradient(90deg, #ef5350, #e53935); }
.api-quota-detail { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.api-quota-tag { font-size: 11px; color: #999; background: #f5f5f5; border-radius: 3px; padding: 1px 5px; }
