/* ==========================================================================
   后台管理样式
   ========================================================================== */

:root {
    --brand: #1667d1;
    --brand-dark: #0e4a9e;
    --brand-light: #e8f1fd;
    --ink: #14203a;
    --ink-2: #33415c;
    --muted: #6c7a95;
    --line: #e5eaf3;
    --bg: #f2f5fa;
    --sidebar: #111c33;
    --sidebar-2: #16233d;
    --radius: 10px;
    --shadow: 0 4px 16px rgba(20, 32, 58, .07);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; line-height: 1.7; color: var(--ink-2); background: var(--bg);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.4; }
input, textarea, select, button { font-family: inherit; font-size: inherit; outline: none; }

/* ---------- 布局 ---------- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 238px; flex-shrink: 0; background: var(--sidebar); color: rgba(255, 255, 255, .68);
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
    transition: transform .3s;
}
.sb-logo { display: flex; align-items: center; gap: 10px; padding: 20px 22px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sb-logo-mark {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; font-weight: 700;
}
.sb-logo-text { line-height: 1.2; }
.sb-logo-text strong { display: block; color: #fff; font-size: 15px; }
.sb-logo-text small { font-size: 10px; letter-spacing: 1.2px; color: rgba(255, 255, 255, .4); }

.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px 30px; }
.sb-group-title { font-size: 11px; letter-spacing: 1.4px; color: rgba(255, 255, 255, .3); padding: 16px 12px 8px; text-transform: uppercase; }
.sb-nav a {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 9px;
    font-size: 14px; margin-bottom: 2px; transition: .2s;
}
.sb-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sb-nav a.active { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; box-shadow: 0 6px 16px rgba(22, 103, 209, .3); }
.sb-nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sb-nav a .badge {
    margin-left: auto; background: #e05353; color: #fff; font-size: 11px; padding: 1px 7px;
    border-radius: 999px; font-weight: 600;
}
.sb-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: rgba(255, 255, 255, .35); }

.admin-main { flex: 1; margin-left: 238px; min-width: 0; display: flex; flex-direction: column; }

.admin-header {
    height: 62px; background: #fff; border-bottom: 1px solid var(--line); display: flex;
    align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 90;
}
.ah-left { display: flex; align-items: center; gap: 16px; }
.ah-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.ah-crumb { font-size: 12.5px; color: var(--muted); }
.ah-right { display: flex; align-items: center; gap: 16px; font-size: 13.5px; }
.ah-right .who { color: var(--muted); }
.ah-right .who strong { color: var(--ink); }
.ah-link { color: var(--muted); }
.ah-link:hover { color: var(--brand); }
.sb-toggle {
    display: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px;
    background: #fff; cursor: pointer; font-size: 16px; color: var(--ink-2);
}

.admin-content { padding: 24px 26px 48px; flex: 1; }

/* ---------- 面板 ---------- */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; }
.panel-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.panel-body { padding: 22px; }
.panel-body.dense { padding: 0; }
.panel-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px; border: 1px solid transparent; font-size: 13.5px;
    font-weight: 600; cursor: pointer; transition: .2s; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-default { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-default:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: #fdeceb; color: #c9382f; border-color: #f7d6d3; }
.btn-danger:hover { background: #e05353; color: #fff; border-color: #e05353; }
.btn-success { background: #eaf7ef; color: #1c7a45; border-color: #cbe9d7; }
.btn-success:hover { background: #1c7a45; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: #fafcff; color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.data tbody tr:hover { background: #f9fbff; }
table.data td.actions { white-space: nowrap; }
table.data td.actions .btn { margin-right: 5px; }
.col-id { width: 60px; }
.col-img img, .col-img .no-img { width: 62px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--brand-light); }
.col-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.t-title { font-weight: 600; color: var(--ink); }
.t-title:hover { color: var(--brand); }
.t-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-on { background: #eaf7ef; color: #1c7a45; }
.badge-off { background: #f1f3f7; color: #7d8798; }
.badge-red { background: #fdeceb; color: #c9382f; }
.badge-blue { background: var(--brand-light); color: var(--brand-dark); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 22px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: block; }
.field > label, .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.field .req { color: #e05353; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field input[type=text], .field input[type=email], .field input[type=number], .field input[type=password],
.field input[type=url], .field textarea, .field select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
    background: #fbfcfe; color: var(--ink); transition: .2s; font-size: 14px;
}
.field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(22, 103, 209, .1);
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-line input { width: 16px; height: 16px; accent-color: var(--brand); }

.form-actions { display: flex; gap: 12px; padding: 18px 22px; border-top: 1px solid var(--line); background: #fafcff; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }

/* 图片上传 */
.uploader { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.uploader-preview {
    width: 150px; height: 106px; border-radius: 8px; border: 1px dashed var(--line); background: #fbfcfe;
    display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; position: relative;
}
.uploader-preview img { width: 100%; height: 100%; object-fit: cover; }
.uploader-preview .del {
    position: absolute; right: 4px; top: 4px; background: rgba(224, 83, 83, .92); color: #fff; border: 0;
    border-radius: 6px; font-size: 11px; padding: 2px 7px; cursor: pointer;
}
.uploader-ctrl { flex: 1; min-width: 220px; }
.uploader-ctrl input[type=file] { font-size: 13px; }
.uploader-ctrl input[type=text] { margin-top: 8px; }

/* 富文本编辑器 */
.editor { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.editor-toolbar {
    display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: #f7f9fd; border-bottom: 1px solid var(--line);
}
.editor-toolbar button {
    border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px 10px;
    cursor: pointer; font-size: 13px; color: var(--ink-2); min-width: 32px;
}
.editor-toolbar button:hover { background: #fff; border-color: var(--line); color: var(--brand); }
.editor-toolbar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.editor-area { min-height: 340px; max-height: 620px; overflow-y: auto; padding: 18px 20px; line-height: 1.9; font-size: 15px; }
.editor-area:focus { outline: none; }
.editor-area p { margin-bottom: 14px; }
.editor-area h2 { font-size: 20px; margin: 22px 0 12px; }
.editor-area h3 { font-size: 17px; margin: 18px 0 10px; }
.editor-area img { max-width: 100%; border-radius: 8px; margin: 12px 0; }
.editor-area ul, .editor-area ol { margin: 0 0 14px 22px; }
.editor-area ul li { list-style: disc; }
.editor-area ol li { list-style: decimal; }
.editor-area blockquote { border-left: 4px solid var(--line); padding: 6px 16px; color: var(--muted); margin: 12px 0; }
.editor-area table, .editor-area th, .editor-area td { border: 1px solid var(--line); border-collapse: collapse; padding: 8px 12px; }

/* ---------- 统计卡片 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.stat-card .sc-ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--brand-light); color: var(--brand); flex-shrink: 0; }
.stat-card .sc-num { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.stat-card .sc-label { font-size: 12.5px; color: var(--muted); }

/* ---------- 提示 ---------- */
.alert { padding: 12px 18px; border-radius: 9px; font-size: 13.5px; margin-bottom: 18px; }
.alert-success { background: #eaf7ef; color: #1c7a45; border-left: 4px solid #34a853; }
.alert-error { background: #fdeceb; color: #b32d26; border-left: 4px solid #e05353; }
.alert-info { background: var(--brand-light); color: var(--brand-dark); border-left: 4px solid var(--brand); }
.alert-warn { background: #fff8e6; color: #946200; border-left: 4px solid #f0b429; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 7px; padding: 18px 22px; flex-wrap: wrap; align-items: center; }
.pager a, .pager span {
    min-width: 34px; height: 34px; padding: 0 11px; border-radius: 7px; display: grid; place-items: center;
    border: 1px solid var(--line); background: #fff; font-size: 13px;
}
.pager a:hover { border-color: var(--brand); color: var(--brand); }
.pager .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.pager .disabled { opacity: .45; }
.pager .gap, .pager .total { border: 0; background: transparent; color: var(--muted); }

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 30px;
    background: linear-gradient(130deg, #0d1a30 0%, #10305e 50%, #1667d1 100%);
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 40px 36px; box-shadow: 0 30px 70px rgba(6, 16, 34, .35); }
.login-card .lg-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 26px; }
.login-card .lg-brand .sb-logo-mark { width: 42px; height: 42px; font-size: 18px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; display: grid; place-items: center; font-weight: 700; }
.login-card h1 { font-size: 21px; text-align: center; }
.login-card .lg-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { margin-top: 8px; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 22px; }
.login-foot a { color: var(--brand); }

/* ---------- 留言详情 ---------- */
.msg-detail { display: grid; gap: 0; }
.msg-row { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.msg-row .k { color: var(--muted); }
.msg-body { background: #fbfcfe; border-radius: 8px; padding: 16px; line-height: 1.8; white-space: pre-wrap; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; opacity: .5; margin-bottom: 10px; }

/* ---------- 遮罩 ---------- */
.sb-mask { display: none; position: fixed; inset: 0; background: rgba(10, 20, 40, .5); z-index: 95; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .admin-main { margin-left: 0; }
    .sb-toggle { display: block; }
    .sb-mask.show { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .admin-content { padding: 18px 15px 40px; }
    .admin-header { padding: 0 15px; }
    .ah-crumb { display: none; }
}
@media (max-width: 560px) {
    .stat-cards { grid-template-columns: 1fr; }
    .login-card { padding: 30px 22px; }
    .panel-head { padding: 15px 16px; }
    .panel-body { padding: 16px; }
}
