/* ===== 设计变量 ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff4ff;
    --text: #1f2937;
    --text-sub: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-soft: #eef1f6;
    --bg: #f5f7fb;
    --card: #ffffff;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }

/* ===== layui 细节微调 ===== */
.layui-btn { border-radius: 8px; font-weight: 500; }
.layui-btn-primary { border-color: var(--border); color: var(--text); }
.layui-btn-primary:hover { border-color: var(--primary); color: var(--primary); }
.layui-btn-normal { background-color: var(--primary); }
.layui-btn-normal:hover { background-color: var(--primary-dark); }
.layui-input, .layui-textarea, .layui-select { border-radius: 8px; border-color: var(--border); }
.layui-input:focus, .layui-textarea:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.layui-form-select dl { border-radius: 8px; border-color: var(--border); }
.layui-form-select dl dd.layui-this { background-color: var(--primary-soft); color: var(--primary); }
.layui-table-view { border-radius: var(--radius); overflow: hidden; border-color: var(--border-soft); }
.layui-table th { background: #fafbfd !important; color: var(--text-sub); font-weight: 600; }
.layui-table-cell { height: auto; line-height: 24px; }
/* 分类标签 */
.tag-cat {
    display: inline-block; max-width: 100%; padding: 0 8px; height: 22px; line-height: 22px;
    border-radius: 4px; background: #eef4ff; color: #3b6fd4; font-size: 12px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
/* 资源列表批量归类条 */
.batch-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; margin-bottom: 6px;
    background: #f4f8ff; border-bottom: 1px solid #e3edff;
    font-size: 13px; color: #4b5563;
}
.batch-bar b { color: var(--primary); font-weight: 600; }
.batch-sep { width: 1px; height: 16px; background: #d8e3f6; }
.batch-bar .batch-select {
    width: 180px; height: 32px; line-height: 30px; padding: 0 8px;
    border-color: #d8e3f6; background: #fff; border-radius: 6px;
}
.batch-bar .layui-btn { height: 32px; line-height: 30px; padding: 0 14px; }
/* 「＋新建分类」小链接 */
.new-cat-link {
    display: inline-block; margin-left: 10px; margin-right: 4px; font-size: 12.5px;
    color: var(--primary); white-space: nowrap; vertical-align: middle;
}
.new-cat-link:hover { opacity: .8; text-decoration: underline; }
/* 「分类」下拉面板底部的「＋ 新建分类」项 */
.layui-form-select dl dd.cat-create-item {
    color: var(--primary);
    border-top: 1px solid var(--border-soft);
    margin-top: 4px;
}
.layui-form-select dl dd.cat-create-item .layui-icon { font-size: 13px; margin-right: 3px; }
.layui-form-select dl dd.cat-create-item:hover { background: var(--primary-soft); }

/* 弹窗内「分类下拉 + 新建」同一行：layui 渲染出的下拉是 select 的兄弟节点，
   必须让 .layui-form-select 自己 flex-grow，否则下拉会被挤成一小截 */
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-row > .layui-form-select { flex: 1 1 auto; min-width: 0; }
.cat-row > .new-cat-link { margin: 0; flex: none; }
/* 上传页：分类选择条 */
.up-cat-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 0 0 14px; font-size: 13px; color: var(--text-sub);
}
.up-cat-bar .up-cat-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
.up-cat-bar select {
    width: 200px; height: 34px; line-height: 32px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.up-cat-bar .up-cat-tip { color: #9ca3af; font-size: 12px; }
/* 表单标签统一宽度，避免中文标签换行 */
.layui-form-label {
    width: 104px; padding: 9px 12px; white-space: nowrap;
    color: var(--text-sub); font-weight: 500;
}
.layui-input-block { margin-left: 134px; }
.layui-form-item .layui-input-inline { margin-right: 10px; }
/* 表格卡片底部留白 */
.card > .layui-table-view { margin-bottom: 14px; }
.layui-layer { border-radius: var(--radius) !important; overflow: hidden; }
.layui-layer-title { background: #fff !important; border-bottom: 1px solid var(--border-soft) !important; font-weight: 600; color: var(--text); }
.layui-layer-btn .layui-layer-btn0 { background: var(--primary) !important; border-color: var(--primary) !important; border-radius: 8px; }
.layui-layer-btn a { border-radius: 8px; }
.layui-form-checked[lay-skin=primary] i { border-color: var(--primary) !important; background-color: var(--primary); }
.layui-form-onswitch { border-color: var(--primary); background-color: var(--primary); }
.layui-tab-title .layui-this { color: var(--primary); }
.layui-tab-title .layui-this:after { border-bottom-color: var(--primary); }
.layui-laypage .layui-laypage-curr .layui-laypage-em { background-color: var(--primary); }
.layui-badge { border-radius: 6px; }

/* ===== 登录页 ===== */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 18%, rgba(37, 99, 235, .10), transparent 42%),
        radial-gradient(circle at 88% 78%, rgba(14, 165, 233, .10), transparent 45%),
        #f5f7fb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-wrap { width: 100%; max-width: 440px; }

.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 36px 34px 26px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .10), 0 2px 8px rgba(16, 24, 40, .04);
    border: 1px solid rgba(229, 231, 235, .8);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
    width: 56px; height: 56px; margin: 0 auto 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff; font-size: 28px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
}
.login-brand h1 { font-size: 22px; margin: 0 0 6px; font-weight: 600; letter-spacing: .5px; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 13px; }

.login-input { position: relative; }
.login-input .layui-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    font-size: 17px; color: var(--text-muted); z-index: 2;
}
.login-input .layui-input {
    height: 46px; line-height: 46px; padding-left: 42px; font-size: 14px;
    background: #fafbfd; border-color: #e8ecf3;
}
.login-input .layui-input:focus { background: #fff; }

.login-captcha-row { display: flex; gap: 12px; align-items: stretch; }
.login-input-captcha { flex: 1; }
.captcha-img {
    width: 150px; height: 50px; border-radius: 8px; cursor: pointer;
    border: 1px solid #e8ecf3; background: #fafbfd; object-fit: cover;
}
.captcha-img:hover { border-color: var(--primary); }

.login-btn {
    height: 46px; line-height: 46px; font-size: 15px; letter-spacing: 4px;
    background: linear-gradient(135deg, #3b82f6, #2563eb); border: 0;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .25);
}
.login-btn:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); }

.login-foot {
    display: flex; justify-content: space-between;
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    color: var(--text-muted); font-size: 12px;
}

/* ===== 后台框架 ===== */
.admin-header {
    position: fixed; top: 0; left: 0; right: 0; height: 60px; z-index: 900;
    background: #fff; border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; padding: 0 20px;
}
.admin-logo { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--text); }
.admin-logo .logo-box {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.admin-header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.admin-user {
    display: flex; align-items: center; gap: 8px; padding: 6px 12px;
    border-radius: 10px; cursor: pointer; color: var(--text); transition: background .2s;
}
.admin-user:hover { background: #f3f6fb; }
.admin-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.admin-role {
    font-size: 11px; padding: 1px 7px; border-radius: 6px;
    background: var(--primary-soft); color: var(--primary);
}

.admin-sidebar {
    position: fixed; top: 60px; bottom: 0; left: 0; width: 216px; z-index: 800;
    background: #fff; border-right: 1px solid var(--border-soft);
    padding: 14px 12px; overflow-y: auto;
}
.admin-nav { list-style: none; margin: 0; padding: 0; }
.admin-nav li { margin-bottom: 4px; }
.admin-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 10px;
    color: var(--text-sub); font-size: 14px; transition: all .18s;
}
.admin-nav a i { font-size: 17px; }
.admin-nav a:hover { background: #f4f7fc; color: var(--text); }
.admin-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.admin-nav .nav-group {
    font-size: 11px; color: var(--text-muted); letter-spacing: 1px;
    padding: 14px 14px 8px; text-transform: uppercase;
}

.admin-main {
    margin: 60px 0 0 216px; height: calc(100vh - 60px);
    background: var(--bg);
}
.admin-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ===== 内容页通用 ===== */
.page { padding: 20px 22px 40px; }
.page-head { display: flex; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 19px; font-weight: 600; margin: 0; }
.page-desc { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }
.page-head .spacer { margin-left: auto; }

.card {
    background: var(--card); border-radius: var(--radius);
    border: 1px solid var(--border-soft); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title .bar { width: 3px; height: 15px; border-radius: 2px; background: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    background: #fff; border-radius: var(--radius); padding: 18px;
    border: 1px solid var(--border-soft); box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; flex: 0 0 44px;
    display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.stat-num { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* 文件卡片 */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.file-card {
    border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden;
    background: #fff; transition: all .2s; position: relative;
}
.file-card:hover { border-color: #c7d7fe; box-shadow: 0 6px 18px rgba(37, 99, 235, .10); }
.file-thumb {
    height: 118px; background: #f7f9fc; display: flex; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer; position: relative;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb .type-icon { font-size: 40px; }
.file-thumb .badge {
    position: absolute; left: 8px; top: 8px; font-size: 11px;
    padding: 2px 7px; border-radius: 6px; background: rgba(17, 24, 39, .65); color: #fff;
}
.file-meta { padding: 10px 12px; }
.file-name {
    font-size: 13px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.file-actions { display: flex; gap: 6px; margin-top: 8px; }
.file-actions .layui-btn { height: 26px; line-height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }

/* ===== 上传页 ===== */
.upload-top { display: flex; gap: 18px; align-items: stretch; }

.upload-zone {
    flex: 0 0 330px;
    border: 2px dashed #d7e0ef; border-radius: 14px; background: #fbfcfe;
    padding: 22px 16px; text-align: center; cursor: pointer; transition: all .2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary); background: var(--primary-soft);
}
.upload-zone .up-icon { font-size: 36px; color: #93b4f8; }
.upload-zone h3 { margin: 10px 0 6px; font-size: 15px; font-weight: 600; }
.upload-zone p { margin: 0; color: var(--text-muted); font-size: 12px; }

/* 右侧格式清单 */
.type-panel {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.type-panel-title {
    font-size: 12px; color: var(--text-muted); letter-spacing: .5px;
    margin-bottom: 2px;
}
.type-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 12px; border-radius: 8px;
    background: #fafbfd; border: 1px solid #f1f4f9;
}
.type-row i { font-size: 15px; flex: 0 0 18px; text-align: center; }
.type-row b { flex: 0 0 58px; font-size: 13px; font-weight: 600; color: #374151; }
.type-row span {
    flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 分类标签（设置页） */
.type-hint {
    font-size: 12px; padding: 5px 10px; border-radius: 8px;
    background: #fff; border: 1px solid var(--border-soft); color: var(--text-sub);
    display: inline-flex; align-items: center; gap: 6px;
}

@media (max-width: 760px) {
    .upload-top { flex-direction: column; }
    .upload-zone { flex: none; }
}

.queue { margin-top: 18px; }
.queue-item {
    background: #fff; border: 1px solid var(--border-soft); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 10px; transition: border-color .2s;
}
.queue-item.done { border-color: #bbf7d0; background: #f7fef9; }
.queue-item.error { border-color: #fecaca; background: #fff8f8; }
.queue-top { display: flex; align-items: center; gap: 10px; }
.q-icon { font-size: 20px; color: var(--primary); flex: 0 0 24px; text-align: center; }
.q-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-size { color: var(--text-muted); font-size: 12px; flex: 0 0 auto; }
.q-status { margin-left: auto; font-size: 12px; color: var(--text-sub); flex: 0 0 auto; }
.q-status.ok { color: var(--success); }
.q-status.bad { color: var(--danger); }
.q-bar { height: 6px; border-radius: 4px; background: #eef1f6; margin-top: 10px; overflow: hidden; }
.q-bar-inner {
    height: 100%; width: 0; border-radius: 4px;
    background: linear-gradient(90deg, #60a5fa, #2563eb);
    transition: width .2s;
}
.queue-item.done .q-bar-inner { background: linear-gradient(90deg, #4ade80, #16a34a); }
.queue-item.error .q-bar-inner { background: var(--danger); }
.q-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.q-ops { margin-left: auto; display: flex; gap: 6px; }
.q-ops .layui-btn { height: 24px; line-height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; }

/* 上传成功卡片 */
.up-result { display: flex; gap: 14px; align-items: flex-start; }
.up-result .thumb {
    width: 96px; height: 96px; border-radius: 10px; overflow: hidden; flex: 0 0 96px;
    background: #f4f7fc; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-soft);
}
.up-result .thumb img { width: 100%; height: 100%; object-fit: cover; }
.url-box {
    display: flex; gap: 8px; margin-top: 8px;
}
.url-box input {
    flex: 1; height: 34px; border: 1px solid var(--border); border-radius: 8px;
    padding: 0 10px; font-size: 12.5px; color: var(--text-sub); background: #fafbfd;
}

/* ===== 表格内元素 ===== */
.cell-file { display: flex; align-items: center; gap: 10px; }
.cell-thumb {
    width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex: 0 0 44px;
    background: #f4f7fc; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-soft); cursor: pointer;
}
.cell-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cell-name { font-weight: 500; color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.tag-type {
    display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 6px;
    background: #f2f5fa; color: var(--text-sub);
}

/* ===== 类型选择卡片 ===== */
.type-tile {
    display: flex; gap: 10px; padding: 12px 14px;
    border: 1px solid var(--border-soft); border-radius: 10px;
    cursor: pointer; transition: all .18s; user-select: none; background: #fff;
}
.type-tile:hover { border-color: #c7d7fe; background: #fafcff; }
.type-tile.active { border-color: var(--primary); background: var(--primary-soft); }
.type-tile .tick {
    width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid #cfd8e6;
    display: flex; align-items: center; justify-content: center; flex: 0 0 18px;
    margin-top: 2px; background: #fff; color: transparent; font-size: 12px; font-weight: 700;
}
.type-tile.active .tick { background: var(--primary); border-color: var(--primary); color: #fff; }
.type-tile .t-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.type-tile .t-ext { display: block; color: var(--text-muted); font-size: 11.5px; margin-top: 3px; line-height: 1.6; }

/* ===== 空状态 ===== */.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty i { font-size: 46px; color: #d5dce8; display: block; margin-bottom: 10px; }

/* ===== 提示 toast 兜底 ===== */
.app-toast {
    position: fixed; left: 50%; top: 26px; transform: translateX(-50%);
    background: rgba(17, 24, 39, .88); color: #fff; padding: 9px 18px;
    border-radius: 8px; font-size: 13px; z-index: 99999; transition: opacity .35s, top .35s;
}
.app-toast-error { background: rgba(185, 28, 28, .92); }
.app-toast-hide { opacity: 0; top: 14px; }

/* ===== 响应式 ===== */
.menu-toggle {
    display: none; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-right: 10px; padding: 0;
    border: 1px solid var(--border-soft); border-radius: 10px;
    background: #fff; color: var(--text-sub); font-size: 18px; cursor: pointer;
}
.menu-toggle:hover { border-color: var(--primary); color: var(--primary); }

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }
    .admin-header { padding: 0 12px; }
    .admin-logo { flex-shrink: 0; }
    .admin-logo span { white-space: nowrap; font-size: 15px; }
    .admin-header-right .layui-btn { display: none; }
    .admin-user > span { display: none; }
    .admin-user { padding: 6px 8px; }
    .admin-sidebar {
        display: block; width: 240px; transform: translateX(-100%);
        transition: transform .22s ease; box-shadow: 0 8px 30px rgba(16, 24, 40, .12);
    }
    body.sidebar-open .admin-sidebar { transform: none; }
    body.sidebar-open .sidebar-mask {
        display: block; position: fixed; left: 0; right: 0; top: 60px; bottom: 0;
        background: rgba(17, 24, 39, .28); z-index: 790;
    }
    .admin-main { margin-left: 0; }
    .page { padding: 14px; }
    .login-card { padding: 28px 20px 20px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

.sidebar-mask { display: none; }
