/* ========================================
   二部运营管理平台 - 主样式表
   Layout / Theme / Sidebar / Header
   ======================================== */

/* --- 全局变量：亮色主题 --- */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-header: #ffffff;
    --bg-hover: #f8fafc;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
}

/* --- 深色主题 --- */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-header: #1e293b;
    --bg-hover: #334155;

    --text-main: #e2e8f0;
    --text-muted: #94a3b8;

    --border-color: #334155;
    --primary-light: #1e3a8a;
}

/* --- 基础 --- */
* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}
a { text-decoration: none; color: inherit; }

/* --- 应用主布局 --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
    box-shadow: var(--shadow-md);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 20px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-brand .brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.sidebar.collapsed .brand-text { display: none; }

.sidebar-menu {
    list-style: none;
    padding: 12px 8px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-menu li { margin: 2px 0; }
.sidebar-menu .menu-title {
    padding: 12px 12px 6px;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.sidebar.collapsed .menu-title { display: none; }
.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-sidebar);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
    gap: 12px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-menu a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}
.sidebar-menu a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}
.sidebar-menu a.active {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}
.sidebar.collapsed .sidebar-menu a span { display: none; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 12px;
    color: #64748b;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-footer .footer-text { display: none; }

/* ============ 内容主区 ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ============ 顶部栏 ============ */
.topbar {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: var(--shadow-sm);
}
.topbar .toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.topbar .toggle-btn:hover { background: var(--bg-hover); }

.topbar .page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}
.topbar .date-badge {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-hover);
    border-radius: 20px;
}

.topbar-search {
    flex: 0 1 320px;
    position: relative;
    margin-left: auto;
}
.topbar-search input {
    width: 100%;
    padding: 8px 14px 8px 38px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-hover);
    font-size: 13px;
    color: var(--text-main);
    outline: none;
    transition: border 0.15s, box-shadow 0.15s;
}
.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.topbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
    background: transparent;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-main);
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn .badge-dot {
    position: absolute;
    top: 10px; right: 10px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-header);
}
.avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.15s;
}
.avatar-btn:hover { background: var(--bg-hover); }
.avatar-btn img,
.avatar-btn .avatar-fallback {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.avatar-btn .name { font-size: 13px; font-weight: 500; }

/* ============ 页面容器 ============ */
.page-container {
    padding: 24px;
    flex: 1;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}
.page-header .breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0 0;
}

/* ============ 卡片 ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}
.card-header h5, .card-header h6 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}
.card-body { padding: 20px; }

/* --- 统计卡片 --- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}
.stat-icon.bg-primary   { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.stat-icon.bg-success   { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-icon.bg-warning   { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-icon.bg-danger    { background: linear-gradient(135deg, #ef4444, #f87171); }
.stat-icon.bg-info      { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.stat-icon.bg-purple    { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.stat-card .stat-info { min-width: 0; flex: 1; }
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 4px;
    white-space: nowrap;
}
.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
    line-height: 1.2;
}
.stat-card .stat-trend {
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============ 表格 ============ */
.table {
    color: var(--text-main);
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    background: transparent;
    border-bottom-color: var(--border-color);
    padding: 14px 12px;
    vertical-align: middle;
}
.table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-hover) !important;
    border-bottom: 1px solid var(--border-color);
}
.table tbody tr:hover { background: var(--bg-hover); }

.table-avatar {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    margin-right: 10px;
    vertical-align: middle;
}

/* ============ 徽章 / 状态 ============ */
.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
}
.badge-soft.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-soft.warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.badge-soft.danger  { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-soft.muted   { background: rgba(100, 116, 139, 0.12); color: var(--secondary); }
.badge-soft.info    { background: rgba(6, 182, 212, 0.12); color: var(--info); }
.badge-soft.purple  { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }

/* ============ 按钮 ============ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ============ 图表容器 ============ */
.chart-container {
    width: 100%;
    height: 320px;
}
.chart-container.sm { height: 240px; }
.chart-container.lg { height: 400px; }

/* ============ Modal 补充 ============ */
[data-theme="dark"] .modal-content {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border-color); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--bg-body);
    color: var(--text-main);
    border-color: var(--border-color);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }

/* ============ 排行榜 / 列表 ============ */
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    gap: 12px;
}
.rank-list li:last-child { border-bottom: none; }
.rank-badge {
    width: 26px; height: 26px;
    border-radius: 8px;
    background: var(--bg-hover);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}
.rank-badge.top1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }
.rank-badge.top2 { background: linear-gradient(135deg, #94a3b8, #cbd5e1); color: #fff; }
.rank-badge.top3 { background: linear-gradient(135deg, #f97316, #fdba74); color: #fff; }
.rank-item-body { flex: 1; min-width: 0; }
.rank-item-body .name { font-weight: 500; font-size: 13px; }
.rank-item-body .meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.rank-value { font-weight: 700; color: var(--primary); font-size: 14px; }

/* ============ 通知列表 ============ */
.notice-list { list-style: none; padding: 0; margin: 0; }
.notice-list li {
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    gap: 12px;
}
.notice-list li:last-child { border-bottom: none; }
.notice-icon {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}
.notice-body { flex: 1; min-width: 0; }
.notice-body .title { font-size: 13px; font-weight: 500; }
.notice-body .desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notice-body .time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============ 小组卡片 ============ */
.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.group-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.group-card .group-cover {
    height: 90px;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    position: relative;
}
.group-card.g2 .group-cover { background: linear-gradient(135deg, #10b981, #34d399); }
.group-card.g3 .group-cover { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.group-card .group-body { padding: 16px 20px; }
.group-card .group-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; color: var(--text-main); }
.group-card .group-leader { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.group-card .group-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.group-card .group-stat .num { font-size: 15px; font-weight: 700; color: var(--text-main); }
.group-card .group-stat .lbl { font-size: 11px; color: var(--text-muted); }

/* ============ 设置页 ============ */
.settings-tabs { border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.settings-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    padding: 10px 16px;
    font-weight: 500;
}
.settings-tabs .nav-link.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    background: transparent;
}

.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.color-swatch {
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.15s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text-main); box-shadow: 0 0 0 2px var(--bg-card); }

/* ============ 响应式 ============ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 30px rgba(0,0,0,0.3);
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar.collapsed { width: var(--sidebar-width); }
    .main-content { margin-left: 0 !important; }
    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
    .page-container { padding: 16px; }
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,0.5);
        z-index: 999;
        display: none;
    }
    .mobile-overlay.show { display: block; }
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(100,116,139,0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,0.5); }
