/* 管理后台样式 */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #f6f8fc; color: #1e293b; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

:root {
  --bg: #f6f8fc; --surface: #fff; --border: #e6ebf2; --text: #1e293b; --muted: #64748b;
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-soft: #eef4ff; --danger: #dc2626;
  --success: #059669; --radius: 14px; --shadow: 0 8px 26px rgba(30,64,175,.07);
}
.wrap { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; transition: .18s; background: #fff; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: #cbd5e1; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 20%, #dbeafe, transparent 45%), radial-gradient(circle at 80% 80%, #cffafe, transparent 45%), #f6f8fc; }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 36px; box-shadow: var(--shadow); }
.login-logo { width: 50px; height: 50px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #38bdf8); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 26px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; outline: none; margin-bottom: 14px; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.login-card .btn { width: 100%; padding: 12px; }
.login-foot { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; }

/* 框架 */
.hidden { display: none !important; }
.admin-shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--border); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-weight: 700; font-size: 16px; }
.side-brand span { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #38bdf8); color: #fff; display: grid; place-items: center; font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px; color: #475569; font-weight: 500; cursor: pointer; transition: .18s; }
.side-nav a:hover { background: #f1f5f9; }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.side-nav .nav-icon { width: 20px; text-align: center; font-size: 16px; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--border); color: #94a3b8; font-size: 11.5px; }
.admin-main { min-width: 0; }
.topbar { height: 68px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 30px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 17px; margin: 0; }
.topbar-actions { display: flex; gap: 9px; }
.admin-content { padding: 26px 30px 60px; max-width: 1280px; }

.view { display: none; }
.view.active { display: block; }
.view-head { margin-bottom: 22px; }
.view-head h3 { font-size: 22px; margin: 0 0 5px; }
.view-head p { color: var(--muted); margin: 0; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card h4 { margin: 0 0 16px; font-size: 16px; }

/* 概览 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat .s-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--primary-soft); margin-bottom: 12px; }
.stat strong { display: block; font-size: 27px; line-height: 1.2; }
.stat small { color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.quick { border: 1px solid var(--border); border-radius: 12px; padding: 16px; cursor: pointer; transition: .18s; background: #fff; }
.quick:hover { border-color: var(--primary); transform: translateY(-2px); }
.quick strong { display: block; margin-bottom: 4px; }
.quick small { color: var(--muted); }

/* 表单 */
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: #475569; }
.field input, .field textarea, .field select { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: #fff; transition: .18s; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: #f8fafc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .cell-title { font-weight: 600; }
td .cell-sub { color: var(--muted); font-size: 12px; }

/* 音频文件列表：固定列宽，防止备注/文件名撑开而挤乱后面的列 */
.sub-table { table-layout: fixed; min-width: 1000px; }
.sub-table th, .sub-table td { padding: 10px; }
.sub-table th { white-space: nowrap; }
.sub-table .badge { white-space: nowrap; }
/* 提交人一行不换行；备注最多 2 行，超出省略 */
.sub-table td:nth-child(1) .cell-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-table td:nth-child(1) .cell-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
/* 音频文件名单行展示，超出省略（悬停看全名） */
.sub-table td:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 大小 / 状态 / 提交时间 / 操作 都不换行 */
.sub-table td:nth-child(3), .sub-table td:nth-child(4),
.sub-table td:nth-child(5), .sub-table td:nth-child(6) { white-space: nowrap; }
.sub-table td:nth-child(6) { padding-right: 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #f1f5f9; color: #475569; }
.badge.pending { background: #fff7ed; color: #c2410c; }
.badge.processing { background: #eff6ff; color: #2563eb; }
.badge.done { background: #ecfdf5; color: #059669; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn.active { outline: 2px solid #2563eb; outline-offset: 1px; background: #eff6ff; color: #1d4ed8; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-row select, .filter-row input { padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: #fff; }
.filter-row input { flex: 1; min-width: 160px; }

/* 稿件：男女选择按钮 + 列表 */
.gender-pick { display: inline-flex; gap: 8px; margin-bottom: 16px; }
.gp-btn { padding: 9px 22px; border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; }
.gp-btn:hover { border-color: var(--primary); color: var(--primary); }
.gp-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.list-head h4 { margin: 0; }
.list-head .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.list-head .seg button { border: 0; background: #fff; color: var(--muted); padding: 7px 16px; cursor: pointer; font-size: 13px; border-right: 1px solid var(--border); }
.list-head .seg button:last-child { border-right: 0; }
.list-head .seg button.active { background: var(--primary); color: #fff; }
.script-admin-list { display: flex; flex-direction: column; gap: 10px; }
.script-admin-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.sai-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; background: #eff6ff; color: var(--primary); font-size: 11px; font-weight: 700; }
.sai-main { min-width: 0; flex: 1; }
.sai-title { font-weight: 600; font-size: 14px; word-break: break-all; }
.sai-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.script-admin-item .row-actions { flex-shrink: 0; }

/* 教程编辑 */
.section-editor { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #f8fafc; }
.section-editor .se-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-editor strong { color: var(--muted); font-size: 12px; }
.editor-list { max-height: 560px; overflow-y: auto; padding-right: 4px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 90; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(680px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px; box-shadow: 0 24px 70px rgba(15,23,42,.25); }
.modal h4 { margin: 0 0 14px; font-size: 17px; }
.modal audio { width: 100%; margin: 12px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.preview-current { max-width: 640px; }
.preview-current .pc-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.preview-current .pc-desc { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.preview-current .pc-meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.preview-current audio { width: 100%; }

/* 音频文件夹管理 */
.folder-form { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.folder-form input { flex: 1; min-width: 180px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; }
.folder-form input:focus { border-color: var(--primary); }
.folder-admin-list { display: flex; flex-wrap: wrap; gap: 9px; }
.folder-admin-item { position: relative; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; background: #fff; }
.fai-ico { position: relative; font-size: 18px; line-height: 1; }
/* 新上传未处理角标：贴在文件夹图标左上角，红底白字 */
.fai-badge { position: absolute; top: -7px; right: auto; left: -9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; line-height: 16px; text-align: center; letter-spacing: 0; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(220,38,38,.35); }
.folder-admin-item.has-pending { border-color: #f7c9cb; background: #fffafb; }
.fai-main { display: flex; flex-direction: column; min-width: 56px; }
.fai-main strong { font-size: 13px; }
.fai-main small { color: var(--muted); font-size: 11px; }
/* 文件夹删除按钮：弱化 + 缩小，避免误点；hover 才显危险态 */
.btn-del-folder { padding: 1px 7px; font-size: 11px; line-height: 1.6; font-weight: 500; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #b6bfcd; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn-del-folder:hover { background: #fff1f2; border-color: #fecdd3; color: var(--danger); }

/* 删除文件夹密码确认弹窗 */
.modal.modal-sm { width: min(420px, 100%); }
.del-folder-tip { margin: 0 0 16px; font-size: 13px; color: #475569; }
.del-folder-tip span { color: var(--muted); font-size: 12.5px; }
.del-folder-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: -6px 0 2px; }

/* 提示 */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 9px; }
.toast { min-width: 220px; max-width: 360px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow); animation: slide .22s; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-nav a { white-space: nowrap; }
  .side-foot { display: none; }
  .topbar, .admin-content { padding-left: 16px; padding-right: 16px; }
  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
  .script-admin-item { flex-wrap: wrap; }
  .script-admin-item .row-actions { width: 100%; }
}
