/* ===== 管理后台样式 ===== */
:root {
    --adm-primary: #3b82f6;
    --adm-primary-dark: #2563eb;
    --adm-bg: #f4f6fb;
    --adm-card: #ffffff;
    --adm-text: #1f2937;
    --adm-muted: #6b7280;
    --adm-border: #e5e7eb;
    --adm-side: #1e293b;
    --adm-side2: #0f172a;
    --adm-radius: 14px;
    --adm-shadow: 0 4px 18px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body.adm-body {
    margin: 0;
    padding: 0;
    background: var(--adm-bg);
    color: var(--adm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--adm-primary); text-decoration: none; }
a:hover { color: var(--adm-primary-dark); }

/* ---------- 布局 ---------- */
.adm-wrap { display: flex; min-height: 100vh; }

.adm-side {
    width: 232px;
    flex: 0 0 232px;
    background: linear-gradient(180deg, var(--adm-side) 0%, var(--adm-side2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.adm-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.adm-brand h1 {
    margin: 0;
    font-size: 17px;
    color: #fff;
    font-weight: 600;
    letter-spacing: .5px;
}
.adm-brand p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #94a3b8;
}

.adm-nav { padding: 12px 10px; flex: 1; }
.adm-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    transition: background .2s, color .2s;
    user-select: none;
}
.adm-nav-item i { width: 18px; text-align: center; }
.adm-nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.adm-nav-item.active {
    background: linear-gradient(90deg, var(--adm-primary) 0%, var(--adm-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, .35);
}
.adm-nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, .16);
    border-radius: 10px;
    padding: 0 8px;
    font-size: 12px;
}
.adm-nav-item.active .adm-nav-badge { background: rgba(255, 255, 255, .25); }

.adm-side-foot {
    padding: 14px 20px 20px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 12px;
    color: #94a3b8;
}
.adm-side-foot a { color: #93c5fd; }

.adm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.adm-topbar {
    background: var(--adm-card);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--adm-border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.adm-topbar h2 { margin: 0; font-size: 18px; font-weight: 600; }
.adm-topbar .adm-sub { color: var(--adm-muted); font-size: 13px; }
.adm-topbar .adm-spacer { flex: 1; }

.adm-content { padding: 22px 24px 40px; }

/* ---------- 通用组件 ---------- */
.adm-card {
    background: var(--adm-card);
    border-radius: var(--adm-radius);
    box-shadow: var(--adm-shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.adm-card h3 {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.adm-card h3 small { font-weight: 400; color: var(--adm-muted); font-size: 12px; }

.adm-grid { display: grid; gap: 16px; }
.adm-grid-4 { grid-template-columns: repeat(4, 1fr); }
.adm-grid-3 { grid-template-columns: repeat(3, 1fr); }
.adm-grid-2 { grid-template-columns: repeat(2, 1fr); }

.adm-stat {
    background: var(--adm-card);
    border-radius: var(--adm-radius);
    box-shadow: var(--adm-shadow);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.adm-stat-icon {
    width: 46px; height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
}
.adm-stat-num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.adm-stat-label { color: var(--adm-muted); font-size: 13px; }

.adm-chart { width: 100%; height: 300px; }

.adm-table-wrap { overflow-x: auto; }
table.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.adm-table th, table.adm-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--adm-border);
    text-align: left;
    vertical-align: middle;
}
table.adm-table th { color: var(--adm-muted); font-weight: 600; white-space: nowrap; }
table.adm-table tbody tr:hover { background: #f8fafc; }
table.adm-table td.adm-ellipsis { max-width: 320px; }
.adm-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--adm-border);
    background: #fff;
    color: var(--adm-text);
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 13px;
    cursor: pointer;
    transition: all .18s;
    font-family: inherit;
}
.adm-btn:hover { border-color: var(--adm-primary); color: var(--adm-primary); }
.adm-btn-primary {
    background: linear-gradient(90deg, var(--adm-primary), var(--adm-primary-dark));
    border-color: transparent;
    color: #fff;
}
.adm-btn-primary:hover { color: #fff; filter: brightness(1.06); }
.adm-btn-danger { color: #dc2626; border-color: #fecaca; }
.adm-btn-danger:hover { background: #fef2f2; color: #b91c1c; border-color: #dc2626; }
.adm-btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.adm-btn:disabled { opacity: .5; cursor: not-allowed; }

.adm-input, .adm-select, .adm-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--adm-border);
    border-radius: 9px;
    font-size: 13px;
    font-family: inherit;
    color: var(--adm-text);
    background: #fff;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.adm-input:focus, .adm-select:focus, .adm-textarea:focus {
    border-color: var(--adm-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
.adm-textarea { min-height: 78px; resize: vertical; }

.adm-field { margin-bottom: 14px; }
.adm-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--adm-muted);
}
.adm-field .adm-hint { font-size: 12px; color: #9ca3af; margin-top: 5px; }

.adm-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.adm-switch input { display: none; }
.adm-switch .adm-track {
    width: 42px; height: 23px;
    background: #cbd5e1;
    border-radius: 999px;
    position: relative;
    transition: background .2s;
    flex: 0 0 42px;
}
.adm-switch .adm-track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 19px; height: 19px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.adm-switch input:checked + .adm-track { background: var(--adm-primary); }
.adm-switch input:checked + .adm-track::after { transform: translateX(19px); }

.adm-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.adm-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.adm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--adm-primary-dark);
    font-size: 12px;
    margin: 0 6px 6px 0;
}
.adm-chip.gray { background: #f1f5f9; color: #64748b; }
.adm-chip .adm-chip-x { cursor: pointer; opacity: .6; }
.adm-chip .adm-chip-x:hover { opacity: 1; }

.adm-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    background: #f1f5f9;
    color: #64748b;
}
.adm-badge.green { background: #dcfce7; color: #15803d; }
.adm-badge.red { background: #fee2e2; color: #b91c1c; }
.adm-badge.blue { background: #dbeafe; color: #1d4ed8; }
.adm-badge.amber { background: #fef3c7; color: #b45309; }

.adm-empty { text-align: center; color: var(--adm-muted); padding: 40px 0; }
.adm-empty i { font-size: 40px; opacity: .3; display: block; margin-bottom: 10px; }

.adm-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: #111827;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s, transform .25s;
    z-index: 999;
    pointer-events: none;
}
.adm-toast.show { opacity: 1; transform: none; }

.adm-pagination { display: flex; justify-content: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.adm-page-btn {
    min-width: 34px;
    padding: 6px 10px;
    border: 1px solid var(--adm-border);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.adm-page-btn.active { background: var(--adm-primary); color: #fff; border-color: var(--adm-primary); }

.adm-model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.adm-model-card {
    border: 2px solid var(--adm-border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all .18s;
    background: #fff;
}
.adm-model-card:hover { border-color: #93c5fd; transform: translateY(-2px); }
.adm-model-card.active { border-color: var(--adm-primary); background: #eff6ff; }
.adm-model-card .adm-model-avatar {
    width: 54px; height: 54px;
    border-radius: 50%;
    margin: 0 auto 8px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #93c5fd, #3b82f6);
    color: #fff; font-size: 22px;
}
.adm-model-card .adm-model-name { font-size: 13px; }

.adm-loading { text-align: center; padding: 60px 0; color: var(--adm-muted); }
.adm-loading i { font-size: 28px; animation: adm-spin 1s linear infinite; }
@keyframes adm-spin { to { transform: rotate(360deg); } }

.adm-section { display: none; }
.adm-section.active { display: block; }

.adm-preview-color {
    width: 34px; height: 34px;
    border-radius: 9px;
    border: 1px solid var(--adm-border);
    cursor: pointer;
    padding: 0;
}

.adm-kv { font-size: 13px; }
.adm-kv div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--adm-border); }
.adm-kv div:last-child { border-bottom: none; }
.adm-kv span:first-child { color: var(--adm-muted); }

.adm-search-box { position: relative; max-width: 320px; flex: 1; }
.adm-search-box input { padding-left: 34px; }
.adm-search-box i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

@media (max-width: 992px) {
    .adm-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .adm-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .adm-wrap { flex-direction: column; }
    .adm-side {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }
    .adm-brand, .adm-side-foot { display: none; }
    .adm-nav { display: flex; gap: 6px; padding: 10px; }
    .adm-nav-item { margin: 0; white-space: nowrap; }
    .adm-nav-badge { display: none; }
    .adm-content { padding: 16px 14px 30px; }
    .adm-grid-4, .adm-grid-2 { grid-template-columns: 1fr; }
}


/* ===== 写文章（编辑器） ===== */
.cmp-wrap {
    display: grid;
    grid-template-columns: 288px 1fr;
    gap: 16px;
    align-items: start;
}
.cmp-side {
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    background: #fbfcfe;
    padding: 12px;
}
.cmp-side-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 10px;
}
.cmp-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    max-height: 460px;
    overflow-y: auto;
}
.cmp-list li {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
}
.cmp-list li:hover { background: #eef4ff; }
.cmp-list li.active { background: #e0edff; border-color: #93c5fd; }
.cmp-list li img {
    width: 46px; height: 34px;
    object-fit: cover;
    border-radius: 6px;
    flex: 0 0 46px;
}
.cmp-list .cmp-t { font-size: 13px; font-weight: 600; }
.cmp-list .cmp-m { font-size: 12px; color: var(--adm-muted); }
.cmp-list .cmp-ops { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.cmp-list .cmp-ops i { cursor: pointer; color: var(--adm-muted); }
.cmp-list .cmp-ops i:hover { color: var(--adm-primary); }
.cmp-list .empty { justify-content: center; color: var(--adm-muted); font-size: 13px; cursor: default; }

.cmp-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cmp-meta .span-2 { grid-column: 1 / -1; }
.cmp-meta label span { font-size: 13px; color: var(--adm-muted); }
.cmp-cover-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cmp-cover-drop {
    width: 88px; height: 56px;
    border: 1px dashed var(--adm-border);
    border-radius: 8px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: #f8fafc;
}
.cmp-cover-drop.dragover { border-color: var(--adm-primary); background: #eff6ff; }
.cmp-cover-drop img { width: 100%; height: 100%; object-fit: cover; }

.cmp-toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 14px 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--adm-border);
}
.cmp-toolbar button {
    border: 1px solid var(--adm-border);
    background: #fff;
    border-radius: 7px;
    padding: 4px 9px;
    font-size: 12px;
    cursor: pointer;
    color: var(--adm-text);
}
.cmp-toolbar button:hover { border-color: var(--adm-primary); color: var(--adm-primary); }
.cmp-spacer { flex: 1; }
.cmp-counter { font-size: 12px; color: var(--adm-muted); align-self: center; }

.cmp-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-panes.preview-off { grid-template-columns: 1fr; }
.cmp-panes.preview-off .cmp-preview { display: none; }
.cmp-editor {
    min-height: 480px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
}
.cmp-preview {
    min-height: 480px;
    width: 100%;
    border: 1px solid var(--adm-border);
    border-radius: 9px;
    background: #fff;
}
.cmp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.cmp-dirty { color: #b45309; font-size: 12px; }

.cmp-login {
    text-align: center;
    padding: 26px 20px;
    border: 1px dashed var(--adm-border);
    border-radius: 12px;
    background: #fbfcfe;
}
.cmp-login .cmp-login-box { max-width: 320px; margin: 0 auto; text-align: left; }
.cmp-login h4 { margin: 0 0 10px; font-size: 15px; }
.cmp-login .adm-field { margin-bottom: 10px; }
.cmp-login .adm-hint { font-size: 12px; color: var(--adm-muted); margin-top: 8px; }

.cmp-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #f1f5f9;
    color: #64748b;
}
.cmp-mode.on { background: #dcfce7; color: #15803d; }
.cmp-mode.off { background: #fef3c7; color: #b45309; }

.cmp-steps { font-size: 13px; color: var(--adm-muted); line-height: 1.8; margin: 0; padding-left: 20px; }
.cmp-steps code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 12px; }

@media (max-width: 1100px) {
    .cmp-wrap { grid-template-columns: 1fr; }
    .cmp-panes { grid-template-columns: 1fr; }
    .cmp-list { max-height: 260px; }
}
@media (max-width: 768px) {
    .cmp-meta { grid-template-columns: 1fr; }
}

/* 顶栏当前管理员身份 */
.adm-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(126, 166, 255, .1);
    border: 1px solid var(--adm-border);
    color: var(--adm-muted);
    font-size: 12.5px;
}
.adm-user i { color: var(--adm-primary); }
