/* ==========================================================================
   资源推荐站 · 后台样式
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-rgb: 37, 99, 235;
    --primary-strong: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .1);
    --bg: #f2f5fa;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-3: #eef2f8;
    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    --border: #e4e8f0;
    --danger: #dc2626;
    --success: #0f9d58;
    --warning: #b45309;
    --sidebar-w: 236px;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 10px 28px rgba(16, 24, 40, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

html, body { margin: 0; padding: 0; }
body.admin-body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-strong); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
p { margin: 0; }
img { max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary); color: #fff; }

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

.admin-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: #0f1a2e;
    color: #c7d2e3;
    display: flex;
    flex-direction: column;
    z-index: 120;
    overflow-y: auto;
}
.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.admin-brand:hover { color: #fff; }
.admin-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
}
.admin-nav { padding: 12px 10px 20px; flex: 1; }
.admin-nav-group { margin-bottom: 14px; }
.admin-nav-title {
    font-size: 11px;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #64748b;
    padding: 6px 12px;
    margin-bottom: 4px;
}
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #c7d2e3;
    font-size: 13.5px;
    transition: background .16s ease, color .16s ease;
}
.admin-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.admin-nav a.is-active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-nav .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .55;
    flex-shrink: 0;
}
.admin-side-foot {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-side-foot a,
.admin-side-foot button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: none;
    border: 0;
    color: #94a3b8;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    width: 100%;
}
.admin-side-foot a:hover,
.admin-side-foot button:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 60px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}
.admin-topbar h1 { font-size: 17px; }
.admin-topbar .admin-top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.admin-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.admin-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text-2);
}
.admin-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}
.admin-content { padding: 22px 24px 46px; flex: 1; }
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 16, 28, .5);
    z-index: 110;
    display: none;
}
body.admin-nav-open .admin-overlay { display: block; }

/* ---------- 通用 ---------- */
.admin-content .flash-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 15px;
    border-radius: 10px;
    font-size: 13.5px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.flash-success { border-color: rgba(15, 157, 88, .3); background: rgba(15, 157, 88, .08); color: #0b7a45; }
.flash-error { border-color: rgba(220, 38, 38, .3); background: rgba(220, 38, 38, .07); color: #b91c1c; }
.flash-info { border-color: rgba(37, 99, 235, .3); background: var(--primary-soft); color: var(--primary-strong); }
.flash-close { background: none; border: 0; font-size: 19px; line-height: 1; color: inherit; cursor: pointer; opacity: .7; }

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.page-toolbar .toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.btn:hover { color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); color: #fff; }
.btn-ghost { border-color: var(--border); background: var(--surface); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(220, 38, 38, .08); color: var(--danger); border-color: rgba(220, 38, 38, .2); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; font-size: 13px; }
.link-btn.danger { color: var(--danger); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { font-size: 15px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.panel-note {
    padding: 11px 14px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 12.5px;
    margin-bottom: 14px;
}
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- 统计 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 25px; font-weight: 800; margin-top: 6px; line-height: 1.2; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-card.accent { background: linear-gradient(135deg, var(--primary), #4f46e5); color: #fff; border-color: transparent; }
.stat-card.accent .stat-label, .stat-card.accent .stat-foot { color: rgba(255, 255, 255, .8); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* 图表 */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart-bar {
    width: 100%;
    max-width: 34px;
    min-height: 3px;
    border-radius: 5px 5px 0 0;
    background: linear-gradient(180deg, #60a5fa, var(--primary));
    position: relative;
    transition: filter .16s ease;
}
.chart-bar:hover { filter: brightness(1.1); }
.chart-bar span {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--muted);
    display: none;
    white-space: nowrap;
}
.chart-bar:hover span { display: block; }
.chart-x { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table .actions form { margin: 0; }
.table img.thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.table .cell-title { font-weight: 600; color: var(--text); }
.table .cell-sub { color: var(--muted); font-size: 12px; }
.table .empty-row td { text-align: center; color: var(--muted); padding: 32px 16px; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
}
.badge-on { background: rgba(15, 157, 88, .12); color: #0b7a45; }
.badge-off { background: var(--surface-3); color: var(--muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: rgba(245, 158, 11, .14); color: var(--warning); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 14px 18px; flex-wrap: wrap; }
.pager-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
}
.pager-link:hover { border-color: var(--primary); color: var(--primary); }
.pager-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-gap { color: var(--muted); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-help { font-size: 11.5px; color: var(--muted); }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="color"],
.field select,
.field textarea,
.toolbar-search input,
.toolbar-search select {
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .toolbar-search input:focus, .toolbar-search select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input[type="color"] { padding: 3px; height: 40px; cursor: pointer; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.toolbar-search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-search input { min-width: 200px; }
.toolbar-search select { min-width: 130px; }

.upload-field { display: flex; gap: 8px; align-items: flex-start; }
.upload-field input { flex: 1; }
.upload-preview {
    margin-top: 8px;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    border: 1px dashed var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }

/* 语言切换 */
.lang-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.lang-tab {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.lang-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lang-panel { display: none; }
.lang-panel.is-active { display: block; }

/* 简易富文本编辑器 */
.editor { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.editor-toolbar button {
    min-width: 30px;
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
}
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border); color: var(--primary); }
.editor-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.editor-body {
    min-height: 220px;
    max-height: 560px;
    overflow-y: auto;
    padding: 14px 16px;
    outline: none;
    font-size: 14px;
    line-height: 1.8;
}
.editor-body img { max-width: 100%; border-radius: 8px; }
.editor-body:focus { background: #fff; }
.editor-body:empty::before { content: "在这里输入内容…"; color: #98a2b3; }

/* ---------- 设置 ---------- */
.settings-section { margin-bottom: 18px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.settings-grid .full { grid-column: 1 / -1; }

/* ---------- 登录 ---------- */
.admin-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(800px 400px at 20% -10%, rgba(59, 130, 246, .3), transparent 60%),
        radial-gradient(700px 500px at 90% 110%, rgba(124, 58, 237, .25), transparent 60%),
        #0b1220;
    padding: 20px;
}
.admin-login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.admin-login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.admin-login-brand .admin-brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; }
.admin-login-brand strong { font-size: 17px; display: block; color: #101828; }
.admin-login-brand small { color: #667085; font-size: 12px; }
.admin-login-card h1 { font-size: 20px; margin-bottom: 4px; color: #101828; }
.admin-login-card .login-sub { color: #667085; font-size: 13px; margin-bottom: 20px; }
.admin-login-card .field input { background: #f8fafc; }
.admin-login-foot { margin-top: 16px; text-align: center; font-size: 12.5px; color: #667085; }

/* ---------- 响应式 ---------- */
@media (max-width: 1199px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991px) {
    .admin-side { transform: translateX(-100%); transition: transform .24s ease; }
    body.admin-nav-open .admin-side { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-menu-btn { display: inline-flex; }
    .admin-content { padding: 18px 14px 40px; }
    .admin-topbar { padding: 0 14px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
    .stat-grid { grid-template-columns: minmax(0, 1fr); }
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .admin-topbar h1 { font-size: 15px; }
    .admin-user-chip span { display: none; }
    .chart { height: 160px; gap: 3px; }
    .chart-x { display: none; }
    .chart-col:nth-child(even) .chart-x { display: block; }
    .table th, .table td { padding: 9px 12px; }
}
