/* 全站主题补全：统一覆盖页面内嵌样式与 Bootstrap 浅色组件 */
[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #1a1a2e;
    --theme-surface: #20203a;
    --theme-surface-strong: #2d2d44;
    --theme-border: #3d3d54;
    --theme-text: #e0e0e0;
    --theme-muted: #a0a0b5;
}

[data-theme="dark"] body,
body[data-theme="dark"] {
    background-color: var(--theme-bg) !important;
    color: var(--theme-text) !important;
}

/* Bootstrap 组件及常见页面容器 */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .card,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .list-group-item,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .popover,
[data-theme="dark"] .offcanvas,
[data-theme="dark"] .accordion-item,
[data-theme="dark"] .accordion-button,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .toast,
[data-theme="dark"] .table,
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text);
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .bg-light,
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-secondary {
    background-color: var(--theme-surface-strong) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] textarea,
[data-theme="dark"] input:not([type="color"]):not([type="range"]),
[data-theme="dark"] select {
    background-color: #25253e !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
    color: #9292aa !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] input:focus {
    background-color: #292943 !important;
    color: var(--theme-text) !important;
    border-color: #6ea8fe !important;
    box-shadow: 0 0 0 .2rem rgba(110,168,254,.2) !important;
}

[data-theme="dark"] .text-dark,
[data-theme="dark"] .text-body,
[data-theme="dark"] .form-label,
[data-theme="dark"] label,
[data-theme="dark"] .card-title,
[data-theme="dark"] .card-text,
[data-theme="dark"] .modal-title,
[data-theme="dark"] .accordion-button,
[data-theme="dark"] .dropdown-item {
    color: var(--theme-text) !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .small.text-muted,
[data-theme="dark"] small,
[data-theme="dark"] .form-text {
    color: var(--theme-muted) !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus,
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus,
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: #3d3d54 !important;
    color: #fff !important;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-end,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start {
    border-color: var(--theme-border) !important;
}

/* 通用项目页面容器、后台内容区和固定白色面板 */
[data-theme="dark"] .admin-main,
[data-theme="dark"] .batch-page,
[data-theme="dark"] .batch-layout,
[data-theme="dark"] .batch-left-panel,
[data-theme="dark"] .batch-center-panel,
[data-theme="dark"] .batch-right-panel,
[data-theme="dark"] .batch-section,
[data-theme="dark"] .batch-model-option,
[data-theme="dark"] .batch-result-cell,
[data-theme="dark"] .model-card,
[data-theme="dark"] .parameter-section,
[data-theme="dark"] .provider-row,
[data-theme="dark"] .slider-defaults-row > div {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text);
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .batch-section-title,
[data-theme="dark"] .batch-model-option .model-name,
[data-theme="dark"] .param-label,
[data-theme="dark"] .project-name,
[data-theme="dark"] .gen-bubble-content,
[data-theme="dark"] .structure-weight-hint,
[data-theme="dark"] .spatial-freedom-hint {
    color: var(--theme-text) !important;
}

[data-theme="dark"] .batch-announcement,
[data-theme="dark"] .batch-stat-item,
[data-theme="dark"] .upload-area,
[data-theme="dark"] .ai-command-box,
[data-theme="dark"] .gen-bubble-content,
[data-theme="dark"] .reference-preview-item,
[data-theme="dark"] .project-badge {
    background-color: var(--theme-surface-strong) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

/* 主题菜单、动态导航下拉和自定义登录弹窗 */
[data-theme="dark"] .theme-menu,
[data-theme="dark"] .nav-dropdown-menu,
[data-theme="dark"] .modal-dialog-custom,
[data-theme="dark"] .custom-color-picker {
    background-color: var(--theme-surface-strong) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
[data-theme="dark"] .nav-dropdown-item,
[data-theme="dark"] .modal-dialog-custom label,
[data-theme="dark"] .modal-title-custom,
[data-theme="dark"] .modal-tab-btn {
    color: var(--theme-text) !important;
}
[data-theme="dark"] .nav-dropdown-item:hover,
[data-theme="dark"] .theme-item:hover,
[data-theme="dark"] .modal-tab-btn:hover {
    background-color: #3d3d54 !important;
    color: #fff !important;
}
[data-theme="dark"] .modal-dialog-custom input,
[data-theme="dark"] .modal-dialog-custom select,
[data-theme="dark"] .modal-dialog-custom textarea {
    background-color: #25253e !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

/* 设计页中仍使用固定浅色值的组件 */
[data-theme="dark"] .slider-control-card,
[data-theme="dark"] .project-card,
[data-theme="dark"] .design-option-card,
[data-theme="dark"] .image-preview-panel,
[data-theme="dark"] .preview-toolbar,
[data-theme="dark"] .ai-history-btn,
[data-theme="dark"] .model-grid-item {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
[data-theme="dark"] .upload-area:hover,
[data-theme="dark"] .batch-model-option:hover,
[data-theme="dark"] .model-grid-item:hover {
    background-color: var(--theme-surface-strong) !important;
}

/* 关闭按钮在深色背景上保持可见 */
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(1.8);
}

/* ============================================================
   深色模式补全（第二批）
   覆盖各页面/组件内硬编码的浅色背景与深灰文字。
   变量沿用文件顶部：--theme-surface / --theme-surface-strong /
   --theme-border / --theme-text / --theme-muted
   ============================================================ */

/* 1. 通用浅色背景/文字（Tailwind 等 CDN 类，用于 case.html、hi.html） */
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100 {
    background-color: var(--theme-surface) !important;
}
[data-theme="dark"] .bg-white\/80,
[data-theme="dark"] .bg-white\/90,
[data-theme="dark"] .bg-white\/95 {
    background-color: rgba(45, 45, 68, 0.92) !important;
    color: var(--theme-text) !important;
}
[data-theme="dark"] .bg-white\/50 {
    background-color: rgba(224, 224, 224, 0.45) !important;
}
[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-800 { color: var(--theme-text) !important; }
[data-theme="dark"] .text-gray-600 { color: var(--theme-muted) !important; }
[data-theme="dark"] .text-gray-500 { color: #8a8aa0 !important; }
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100 { border-color: var(--theme-border) !important; }

/* 2. 3D 预览页（model3d.html / model3d_share.html） */
[data-theme="dark"] .m3d-card { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; }
[data-theme="dark"] .m3d-preview-wrap img { background: var(--theme-surface-strong) !important; }
[data-theme="dark"] .m3d-tool { background: rgba(45, 45, 68, 0.92) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-src-thumb { background: var(--theme-surface-strong) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-view-presets { background: rgba(45, 45, 68, 0.95) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-viewer-box { background: linear-gradient(160deg, #23233a, #1a1a2e) !important; }
[data-theme="dark"] .m3d-hitem { background: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-hitem .thumb { background: var(--theme-surface-strong) !important; }
[data-theme="dark"] .m3d-ui-opt { background: var(--theme-surface-strong) !important; color: #6ea8fe !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-quality-chip,
[data-theme="dark"] .m3d-mode-chip { background: var(--theme-surface-strong) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-view-cell { background: var(--theme-surface-strong) !important; color: var(--theme-muted) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .m3d-pick-item { background: var(--theme-surface-strong) !important; }

[data-theme="dark"] .share-viewer { background: linear-gradient(160deg, #23233a, #1a1a2e) !important; }
[data-theme="dark"] .share-tool { background: rgba(45, 45, 68, 0.92) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .share-src { background: var(--theme-surface-strong) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .share-views { background: rgba(45, 45, 68, 0.95) !important; border-color: var(--theme-border) !important; }

/* 3. 批量工作台 pro.html（pro.css 中未被覆盖的类） */
[data-theme="dark"] .batch-tool-item,
[data-theme="dark"] .batch-mode-btn,
[data-theme="dark"] .batch-template-card,
[data-theme="dark"] .batch-style-tag,
[data-theme="dark"] .batch-style-card,
[data-theme="dark"] .batch-project-item,
[data-theme="dark"] .batch-picker-card,
[data-theme="dark"] .batch-history-round,
[data-theme="dark"] .batch-project-select {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
[data-theme="dark"] .batch-upload-area,
[data-theme="dark"] .batch-upload-square,
[data-theme="dark"] .batch-ref-col,
[data-theme="dark"] .batch-ref-grid,
[data-theme="dark"] .batch-ref-add-single,
[data-theme="dark"] .batch-ref-add-btn,
[data-theme="dark"] .batch-prompt-preview,
[data-theme="dark"] .batch-ref-cell,
[data-theme="dark"] .batch-history-round-head {
    background-color: var(--theme-surface-strong) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
[data-theme="dark"] .batch-stat-val { color: var(--theme-text) !important; }
[data-theme="dark"] .batch-project-name { color: var(--theme-text) !important; }

/* 4. AI 设计页依赖的自定义 CSS */
[data-theme="dark"] .sidebar-btn-full,
[data-theme="dark"] .sidebar-btn,
[data-theme="dark"] .design-mode-btn,
[data-theme="dark"] .param-tool-item,
[data-theme="dark"] .quick-tag {
    background-color: var(--theme-surface-strong) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
[data-theme="dark"] .param-label,
[data-theme="dark"] .model-selection-area .param-label { color: var(--theme-muted) !important; }
[data-theme="dark"] .history-tabs { background-color: var(--theme-surface) !important; }
[data-theme="dark"] .ai-material-popup { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .upload-area:hover { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] .structure-weight-hint { background-color: var(--theme-surface-strong) !important; }

[data-theme="dark"] .ai-top-upload-section { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .batch-upload-area,
[data-theme="dark"] .batch-upload-square { background-color: var(--theme-surface-strong) !important; border-color: var(--theme-border) !important; }

[data-theme="dark"] .image-preview-dialog { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .image-preview-header { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] .preview-move-dropdown { background-color: var(--theme-surface) !important; }

[data-theme="dark"] .project-list-container,
[data-theme="dark"] .move-to-project-dropdown { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }

[data-theme="dark"] .sidebar-popup { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }

/* 5. 案例图库页 case_gallery.html */
[data-theme="dark"] .card-action-btn { background-color: var(--theme-surface-strong) !important; color: var(--theme-text) !important; }
[data-theme="dark"] .load-more-btn { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .skeleton-item { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] .masonry-item img.img-error { background-color: var(--theme-surface-strong) !important; }

/* 6. 充值 / 签到 / 邀请 页 */
[data-theme="dark"] .feature-list li { color: var(--theme-text) !important; }
[data-theme="dark"] .qr-loading { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] .subscription-card,
[data-theme="dark"] .credit-pack-card { border-color: var(--theme-border) !important; }

[data-theme="dark"] .ck-cal-day { background-color: var(--theme-surface-strong) !important; color: var(--theme-muted) !important; }
[data-theme="dark"] .ck-rank-no { background-color: var(--theme-surface-strong) !important; color: var(--theme-text) !important; }
[data-theme="dark"] .ck-rank-item { border-bottom-color: var(--theme-border) !important; }

[data-theme="dark"] .iv-rule-card { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; }
[data-theme="dark"] .iv-record { border-bottom-color: var(--theme-border) !important; }

/* 7. 独立落地页 case.html 的自定义类 */
[data-theme="dark"] .btn-secondary { background-color: var(--theme-surface-strong) !important; color: #6ea8fe !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .btn-secondary:hover { background-color: #3d3d54 !important; }
[data-theme="dark"] .carousel-btn { background-color: rgba(45, 45, 68, 0.9) !important; color: var(--theme-text) !important; }
[data-theme="dark"] .carousel-btn:hover { background-color: rgba(61, 61, 84, 0.95) !important; }

/* 8. 后台 admin 页面 */
[data-theme="dark"] .alert-light { background-color: var(--theme-surface-strong) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .candidate-item,
[data-theme="dark"] .candidate-item:hover { background-color: var(--theme-surface-strong) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .role-stage-box,
[data-theme="dark"] .role-stage1-box,
[data-theme="dark"] .role-stage2-box { background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .role-card { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .role-model { background-color: var(--theme-surface-strong) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .stats-card { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .stage-section { background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .stage1-section { background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important; }
[data-theme="dark"] .stage2-section { background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important; }

/* 9. 内联样式兜底（精确属性选择器，仅匹配特定浅色占位） */
[data-theme="dark"] img[style*="background:#f8f9fa"] { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] div[style*="background:#fafbfc"] { background-color: var(--theme-surface-strong) !important; }
[data-theme="dark"] div[style*="max-height:45px"] { background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
