/* ====== 全局变量 ====== */
:root {
    --red: #C8102E;
    --red-dark: #a00d24;
    --red-light: #fff1f2;
    --blue: #0D4C75;
    --blue-dark: #093a5a;
    --blue-light: #e8f4fd;
    --gold: #d4a843;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text: #2c3e50;
    --text-secondary: #6b7b8d;
    --text-muted: #a0aab4;
    --border: #e4e7ed;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
    --radius: 6px;
    --font: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
}

/* ====== 重置 ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--red); }
img { max-width: 100%; }
ul { list-style: none; }

/* ====== 布局 ====== */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.main-wrapper { display: flex; flex: 1; padding-top: 70px; }
.content { flex: 1; padding: 24px; max-width: 1200px; }

/* ====== 顶栏 ====== */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 70px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-inner {
    max-width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
}
.topbar-brand { display: flex; align-items: center; gap: 20px; }
.topbar-logo { height: 54px; width: auto; }
.topbar-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.25); }
.topbar-system { color: rgba(255,255,255,0.85); font-size: 15px; letter-spacing: 2px; font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: #fff; }
.topbar-username { font-size: 14px; font-weight: 600; }
.topbar-role {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9);
}
.btn-logout {
    color: rgba(255,255,255,0.8); font-size: 13px;
    padding: 6px 14px; border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ====== 侧边栏 ====== */
.sidebar {
    width: 220px; min-width: 220px;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    min-height: calc(100vh - 70px);
}
.sidebar-menu li a {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 24px; color: var(--text-secondary);
    font-size: 14px; transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-menu li a:hover { color: var(--red); background: var(--red-light); }
.sidebar-menu li.active a {
    color: var(--red); background: var(--red-light);
    border-left-color: var(--red); font-weight: 600;
}
.sidebar-menu .icon { font-size: 14px; width: 18px; text-align: center; }
.badge {
    margin-left: auto; background: var(--red); color: #fff;
    font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

/* ====== 页面标题 ====== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 2px solid var(--red);
}
.page-header h1 { font-size: 20px; font-weight: 700; color: var(--blue); }
.page-header .subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }

/* ====== 卡片 ====== */
.card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
}
.card-title {
    font-size: 16px; font-weight: 700; color: var(--blue);
    padding-bottom: 14px; margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

/* ====== 统计面板 ====== */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 24px;
    display: flex; align-items: center; gap: 18px;
    border-top: 3px solid var(--blue);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.red { border-top-color: var(--red); }
.stat-card.gold { border-top-color: var(--gold); }
.stat-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff;
}
.stat-icon.bg-blue { background: linear-gradient(135deg, var(--blue), #1a6fa0); }
.stat-icon.bg-red { background: linear-gradient(135deg, var(--red), #e0354e); }
.stat-icon.bg-gold { background: linear-gradient(135deg, var(--gold), #e6be5a); }
.stat-number { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ====== 表格 ====== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
thead th {
    background: var(--blue); color: #fff;
    padding: 12px 16px; text-align: left;
    font-size: 13px; font-weight: 600;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr:hover { background: #fafbfc; }
tbody tr.unread { background: var(--blue-light); font-weight: 600; }
tbody tr.unread:hover { background: #d6edf9; }
.dot-unread {
    display: inline-block; width: 8px; height: 8px;
    background: var(--red); border-radius: 50%; margin-right: 8px;
}
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--text);
}
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; font-family: var(--font);
    transition: border-color 0.2s;
    background: var(--white); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(13,76,117,0.08); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }

/* ====== 按钮 ====== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 24px; border: none; border-radius: var(--radius);
    font-size: 14px; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; box-shadow: 0 4px 12px rgba(200,16,46,0.3); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: var(--blue-dark); color: #fff; }
.btn-outline {
    background: transparent; color: var(--blue);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--blue); background: var(--blue-light); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; }

/* ====== 提示 ====== */
.alert {
    padding: 12px 18px; border-radius: var(--radius);
    margin-bottom: 20px; font-size: 13px; font-weight: 500;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ====== 消息详情 ====== */
.message-detail { padding: 0; }
.message-detail .msg-header {
    padding: 24px; border-bottom: 1px solid var(--border);
}
.message-detail .msg-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.message-detail .msg-meta { font-size: 13px; color: var(--text-secondary); display: flex; gap: 20px; }
.message-detail .msg-body { padding: 24px; line-height: 1.8; font-size: 15px; }

/* ====== 分页 ====== */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pagination a, .pagination 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: var(--radius);
    font-size: 13px; color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--blue); color: var(--blue); }
.pagination .current { background: var(--red); border-color: var(--red); color: #fff; }

/* ====== 多选发送 ====== */
.user-select-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.user-select-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.15s;
}
.user-select-item:last-child { border-bottom: none; }
.user-select-item:hover { background: var(--blue-light); }
.user-select-item input[type="checkbox"] { accent-color: var(--red); width: 16px; height: 16px; }
.select-actions { display: flex; gap: 10px; margin-bottom: 10px; }

/* ====== 页脚 ====== */
.site-footer {
    text-align: center; padding: 16px;
    color: var(--text-muted); font-size: 12px;
    border-top: 1px solid var(--border); background: var(--white);
}

/* ====== 登录页 ====== */
.login-page {
    min-height: 100vh; display: flex;
    font-family: var(--font);
}
.login-brand {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 50%, #061e30 100%);
    position: relative; overflow: hidden; padding: 40px;
}
.login-brand::before {
    content: ''; position: absolute; top: -50%; right: -50%;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(200,16,46,0.15) 0%, transparent 70%);
}
.login-brand::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 4px; background: linear-gradient(90deg, var(--red), var(--gold), var(--red));
}
.login-brand-logo { width: 160px; margin-bottom: 32px; position: relative; z-index: 1; }
.login-brand h1 {
    color: #fff; font-size: 28px; font-weight: 700;
    letter-spacing: 4px; position: relative; z-index: 1;
}
.login-brand .slogan {
    color: rgba(255,255,255,0.6); font-size: 14px;
    margin-top: 12px; letter-spacing: 2px; position: relative; z-index: 1;
}
.login-brand .decorline {
    width: 60px; height: 3px; background: var(--red);
    margin: 20px 0; position: relative; z-index: 1;
}
.login-form-side {
    width: 480px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px; background: var(--white);
}
.login-form-box { width: 100%; max-width: 360px; }
.login-form-box h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.login-form-box .login-sub { color: var(--text-secondary); font-size: 13px; margin-bottom: 32px; }
.login-form-box .form-control { padding: 12px 16px; font-size: 14px; }
.login-form-box .btn { padding: 12px; font-size: 15px; margin-top: 8px; }
.login-form-box .login-footer {
    text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted);
}
.login-form-box .login-footer a { color: var(--blue); }

/* ====== 弹窗 ====== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal-box {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 28px;
    width: 90%; max-width: 420px;
}
.modal-box h3 {
    font-size: 17px; color: var(--blue);
    margin-bottom: 20px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ====== 移动端响应式 ====== */
@media (max-width: 768px) {
    /* 登录页：全屏背景 + 悬浮卡片 */
    .login-page {
        flex-direction: column; position: relative;
        background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 50%, #061e30 100%);
        min-height: 100vh; align-items: center; justify-content: center;
        padding: 20px;
    }
    .login-brand {
        position: absolute; top: 0; left: 0; right: 0;
        min-height: auto; padding: 40px 20px 20px;
        background: none; z-index: 1;
    }
    .login-brand::before, .login-brand::after { display: none; }
    .login-brand-logo { width: 90px; margin-bottom: 12px; }
    .login-brand h1 { font-size: 17px; letter-spacing: 2px; }
    .login-brand .slogan { font-size: 11px; }
    .login-brand .decorline { margin: 12px 0; }
    .login-form-side {
        width: 100%; max-width: 360px;
        padding: 28px 24px; margin-top: 100px;
        border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
        z-index: 2; background: var(--white);
    }
    .login-form-box { max-width: 100%; }
    .login-form-box h2 { font-size: 19px; }
    .login-form-box .login-footer a { color: var(--blue); }

    /* 顶栏适配 */
    .main-wrapper { flex-direction: column; padding-top: 50px; }
    .topbar { height: 50px; }
    .topbar-inner { padding: 0 10px; }
    .topbar-brand { gap: 8px; }
    .topbar-logo { height: 30px; }
    .topbar-divider { height: 18px; }
    .topbar-system { font-size: 11px; letter-spacing: 1px; white-space: nowrap; }
    .topbar-role { display: none; }
    .topbar-username { font-size: 11px; }
    .btn-logout { padding: 3px 8px; font-size: 11px; }

    .sidebar {
        width: 100%; min-width: 100%; min-height: auto;
        border-right: none; border-bottom: 1px solid var(--border);
        padding: 0; overflow-x: auto;
    }
    .sidebar-menu { display: flex; white-space: nowrap; }
    .sidebar-menu li a {
        padding: 12px 18px; border-left: none;
        border-bottom: 3px solid transparent;
    }
    .sidebar-menu li.active a {
        border-left-color: transparent;
        border-bottom-color: var(--red);
    }

    .content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h1 { font-size: 18px; }

    .message-detail .msg-meta { flex-direction: column; gap: 4px; }
    .message-detail .msg-title { font-size: 17px; }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
    .login-brand { min-height: 160px; }
    .login-brand-logo { width: 80px; }
    .login-brand h1 { font-size: 17px; }
    .card { padding: 16px; }
    .card-title { font-size: 15px; }
}
