/* ===================================================
   星火之光 - 扩展组件样式（在 style.css 之后加载）
   复用 style.css 中的设计变量：品牌色 / 灰阶 / 圆角
   =================================================== */

/* ===== 通用按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #FFF; }
.btn-primary:hover { background: var(--brand-dark); opacity: 1; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); opacity: 1; }
.btn-danger { background: #FFF; border-color: rgba(214, 61, 61, 0.35); color: #C0342B; }
.btn-danger:hover { background: #FDF2F1; border-color: #C0342B; opacity: 1; }
.btn-success { background: #1F8A4C; color: #FFF; }
.btn-success:hover { background: #17703E; opacity: 1; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; border-radius: 10px; }
.btn-block { width: 100%; }

/* ===== 表单 ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink-2);
}
.field label .req { color: #C0342B; margin-left: 2px; }
.field .hint { font-size: 0.75rem; color: var(--ink-3); }
.input, .textarea, .select {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--ink-1);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(51, 84, 170, 0.12);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--ink-2); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--brand); }

/* 文件选择 */
.file-drop {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1px dashed var(--brand-line);
    border-radius: var(--radius-btn);
    background: var(--brand-soft);
    font-size: 0.8125rem; color: var(--ink-2);
    cursor: pointer;
}
.file-drop:hover { border-color: var(--brand); }
.file-drop input[type="file"] { display: none; }
.file-drop .file-name { color: var(--brand); font-weight: 600; }

/* ===== 卡片容器 ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-card);
    padding: 28px;
}
.panel + .panel { margin-top: 20px; }
.panel-title { font-size: 1.125rem; margin-bottom: 6px; }
.panel-sub { color: var(--ink-3); font-size: 0.8125rem; margin-bottom: 20px; }
.form-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }

/* ===== 提示条 ===== */
.alert {
    padding: 12px 16px; border-radius: var(--radius-btn);
    font-size: 0.8125rem; line-height: 1.6; margin-bottom: 16px;
    border: 1px solid var(--line);
    background: var(--canvas); color: var(--ink-2);
}
.alert-info { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-dark); }
.alert-warn { background: #FFF8EC; border-color: rgba(200, 140, 20, 0.3); color: #8A5B00; }
.alert-error { background: #FDF2F1; border-color: rgba(214, 61, 61, 0.3); color: #C0342B; }
.alert-success { background: #EEF9F1; border-color: rgba(31, 138, 76, 0.3); color: #17703E; }

/* ===== Toast ===== */
.xh-toast {
    position: fixed; left: 50%; bottom: 32px;
    transform: translate(-50%, 20px);
    padding: 12px 22px; border-radius: var(--radius-pill);
    background: var(--ink-1); color: #FFF;
    font-size: 0.875rem; box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    opacity: 0; pointer-events: none; transition: all 0.28s ease; z-index: 2000;
    max-width: 88vw; text-align: center;
}
.xh-toast.show { opacity: 1; transform: translate(-50%, 0); }
.xh-toast.error { background: #C0342B; }
.xh-toast.success { background: #1F8A4C; }

/* ===== 书籍卡片 ===== */
/* 书库统一每排 3 个 */
.products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) {
    .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .products-grid { grid-template-columns: 1fr; }
}

.book-card { padding: 16px; gap: 14px; text-decoration: none; }
.book-card:hover { opacity: 1; }
.book-cover {
    width: 100%; aspect-ratio: 3 / 4;
    border-radius: var(--radius-media);
    overflow: hidden; background: linear-gradient(135deg, #EEF2FB, #DCE5F7);
    display: flex; align-items: center; justify-content: center;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; font-weight: 800; color: var(--brand);
    background: linear-gradient(135deg, #E8EEFA, #D3DEFA);
}
.book-body { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-author { color: var(--ink-3); font-size: 0.8125rem; }
.book-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.book-cat {
    font-size: 0.75rem; color: var(--brand); background: var(--brand-soft);
    padding: 2px 10px; border-radius: var(--radius-pill); font-weight: 600;
}
.book-dl { font-size: 0.75rem; color: var(--ink-3); }
.book-tag { font-size: 0.6875rem; color: var(--ink-3); background: var(--canvas); border: 1px solid var(--line-soft); padding: 2px 8px; border-radius: var(--radius-pill); }

/* ===== 筛选栏 ===== */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    padding: 16px; background: var(--surface);
    border: 1px solid var(--line-soft); border-radius: var(--radius-card);
    margin-bottom: 28px;
}
.filter-bar .grow { flex: 1; min-width: 200px; }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 64px 20px; color: var(--ink-3); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 36px; flex-wrap: wrap; }

/* ===== 图书详情 ===== */
.detail-layout {
    display: grid; grid-template-columns: 280px 1fr; gap: 40px;
    align-items: start; padding: 48px 0;
}
.detail-cover {
    width: 100%; aspect-ratio: 3 / 4; border-radius: var(--radius-card);
    overflow: hidden; background: linear-gradient(135deg, #E8EEFA, #D3DEFA);
    box-shadow: 0 12px 32px rgba(51, 84, 170, 0.14);
    display: flex; align-items: center; justify-content: center;
    position: sticky; top: 88px;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-cover .book-cover-placeholder { font-size: 4rem; }
.detail-title { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 10px; }
.detail-sub { color: var(--ink-3); font-size: 0.9375rem; margin-bottom: 20px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.detail-meta {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px; margin-bottom: 28px; padding: 20px;
    background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-card);
}
.detail-meta .k { font-size: 0.75rem; color: var(--ink-3); margin-bottom: 2px; }
.detail-meta .v { font-size: 0.9375rem; color: var(--ink-1); font-weight: 600; word-break: break-all; }
.detail-summary { color: var(--ink-2); line-height: 1.9; font-size: 0.9375rem; white-space: pre-wrap; }
.detail-actions { display: flex; gap: 12px; margin: 28px 0; flex-wrap: wrap; }
.section-label { font-size: 1.0625rem; font-weight: 700; margin: 28px 0 12px; }

/* ===== 上传页 ===== */
.upload-wrap { max-width: 820px; margin: 0 auto; padding: 48px 0; }
.upload-head { text-align: center; margin-bottom: 36px; }
.upload-head h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); margin-bottom: 10px; }
.upload-head p { color: var(--ink-2); }
.steps { display: flex; justify-content: center; gap: 10px; margin-bottom: 32px; flex-wrap: wrap; }
.step-pill { font-size: 0.8125rem; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); padding: 6px 16px; border-radius: var(--radius-pill); }
.step-pill.active { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }

/* ===== 后台布局 ===== */
#admin-app { min-height: 100vh; }
.admin-login-wrap { max-width: 420px; margin: 0 auto; padding: 80px 24px; }
.admin-login-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-card); padding: 36px; box-shadow: 0 12px 40px rgba(51, 84, 170, 0.08); }
.admin-login-card h1 { font-size: 1.375rem; margin-bottom: 6px; text-align: center; }
.admin-login-card .sub { text-align: center; color: var(--ink-3); font-size: 0.8125rem; margin-bottom: 24px; }
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 64px); }
.admin-side {
    background: var(--surface); border-right: 1px solid var(--line-soft); padding: 20px 14px;
}
.admin-side .side-user { padding: 10px 12px 16px; font-size: 0.8125rem; color: var(--ink-3); border-bottom: 1px solid var(--line-soft); margin-bottom: 12px; }
.admin-side .side-user b { display: block; color: var(--ink-1); font-size: 0.9375rem; margin-bottom: 2px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; list-style: none; }
.admin-nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: 10px; color: var(--ink-2); font-size: 0.875rem; font-weight: 500;
}
.admin-nav a:hover { background: var(--brand-soft); color: var(--brand); opacity: 1; }
.admin-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.admin-main { padding: 28px 32px 64px; min-width: 0; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-head h1 { font-size: 1.5rem; }
.admin-head p { color: var(--ink-3); font-size: 0.8125rem; }
.admin-view { display: none; }
.admin-view.active { display: block; }

/* 概览统计 */
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 24px; }
.mini-stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-card); padding: 18px 20px; }
.mini-stat .n { font-size: 1.75rem; font-weight: 800; color: var(--ink-1); letter-spacing: -0.02em; }
.mini-stat .l { font-size: 0.75rem; color: var(--ink-3); margin-top: 2px; }
.mini-stat.brand .n { color: var(--brand); }
.mini-stat.warn .n { color: #B7791F; }
.mini-stat.ok .n { color: #1F8A4C; }

/* 状态标签 */
.status-pill { display: inline-flex; align-items: center; padding: 3px 12px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.status-pending { background: #FFF8EC; color: #8A5B00; }
.status-approved { background: #EEF9F1; color: #17703E; }
.status-rejected { background: #FDF2F1; color: #C0342B; }
.status-needs_info { background: #EEF3FF; color: var(--brand-dark); }

/* 数据列表 */
.data-list { display: flex; flex-direction: column; gap: 12px; }
.data-row {
    display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center;
    padding: 14px 16px; background: var(--surface);
    border: 1px solid var(--line-soft); border-radius: var(--radius-card);
    transition: all 0.2s ease;
}
.data-row:hover { border-color: var(--brand-line); box-shadow: var(--shadow-hover); }
.data-thumb { width: 56px; height: 74px; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, #E8EEFA, #D3DEFA); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--brand); }
.data-thumb img { width: 100%; height: 100%; object-fit: cover; }
.data-main { min-width: 0; }
.data-main .t { font-weight: 600; font-size: 0.9375rem; margin-bottom: 3px; }
.data-main .m { font-size: 0.75rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 10px; }
.data-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* 弹窗 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(20, 23, 28, 0.42);
    display: none; align-items: flex-start; justify-content: center;
    padding: 40px 20px; overflow-y: auto; z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal-mask.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius-card);
    width: 100%; max-width: 720px; padding: 28px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.24);
    animation: modalIn 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-head h3 { font-size: 1.1875rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--ink-1); }
.ai-box { background: var(--canvas); border: 1px solid var(--line-soft); border-radius: var(--radius-btn); padding: 16px; margin-top: 16px; }
.ai-box pre { white-space: pre-wrap; word-break: break-word; font-size: 0.8125rem; color: var(--ink-2); font-family: inherit; max-height: 240px; overflow: auto; }

/* 设置分区 */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.tabbar { display: flex; gap: 6px; border-bottom: 1px solid var(--line-soft); margin-bottom: 22px; flex-wrap: wrap; }
.tabbar button {
    background: none; border: none; font-family: inherit; font-size: 0.875rem; font-weight: 600;
    color: var(--ink-3); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabbar button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-card); background: var(--surface); }
table.log-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
table.log-table th, table.log-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.log-table th { color: var(--ink-3); font-weight: 600; background: var(--canvas); }
table.log-table tr:last-child td { border-bottom: none; }
.log-status.sent { color: #17703E; font-weight: 600; }
.log-status.failed { color: #C0342B; font-weight: 600; }
.log-status.skipped { color: var(--ink-3); }

/* 条幅文本项 */
.banner-item span { font-size: 0.9375rem; color: var(--ink-2); font-weight: 600; }

/* 加载 */
.loading { text-align: center; padding: 40px; color: var(--ink-3); font-size: 0.875rem; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; gap: 24px; }
    .detail-cover { max-width: 240px; margin: 0 auto; position: static; }
    .admin-shell { grid-template-columns: 1fr; }
    .admin-side { border-right: none; border-bottom: 1px solid var(--line-soft); padding: 12px; }
    .admin-nav { flex-direction: row; overflow-x: auto; }
    .admin-nav a { white-space: nowrap; }
    .admin-main { padding: 20px 16px 64px; }
    .data-row { grid-template-columns: 48px 1fr; }
    .data-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .panel { padding: 20px; }
    .modal { padding: 20px; }
}