/*
 * 全站暗黑模式样式
 * 加载于各页面内联样式之后，通过 html[data-theme="dark"] 覆盖页面中写死的浅色值。
 * 亮色模式完全沿用各页面原有样式，本文件仅在 data-theme="dark" 时生效。
 */

html[data-theme="dark"] {
    color-scheme: dark;
}

/* ---------------- 事件详情趋势图 ---------------- */
html[data-theme="dark"] .trend-head {
    color: #e2e8f0;
}
html[data-theme="dark"] .modal-meta .meta-value {
    color: #e2e8f0;
}
html[data-theme="dark"] .trend-chart-title,
html[data-theme="dark"] .trend-note,
html[data-theme="dark"] .trend-empty {
    color: #94a3b8;
}
html[data-theme="dark"] .tc-grid {
    stroke: #334155;
}
html[data-theme="dark"] .tc-dot {
    stroke: #0f172a;
}

/* ---------------- 页面基础 ---------------- */
html[data-theme="dark"] body {
    background: #0f172a !important;
    background-image: none !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .header {
    background: rgba(15, 23, 42, 0.95) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55) !important;
}

html[data-theme="dark"] .header h1,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .detail-value {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .nav {
    background: rgba(15, 23, 42, 0.9) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55) !important;
}

html[data-theme="dark"] .nav a {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .nav a:hover {
    color: #60a5fa !important;
}

/* ---------------- 容器与卡片 ---------------- */
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .box,
html[data-theme="dark"] .login-box,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .idle-box,
html[data-theme="dark"] .idle-warning-box {
    background: #1e293b !important;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.5) !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .metric strong,
html[data-theme="dark"] .card strong,
html[data-theme="dark"] .metric .value {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .version-item,
html[data-theme="dark"] .entry-item {
    background: #0f172a !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .detail-grid {
    background: #111b2e !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .config-preview,
html[data-theme="dark"] .json,
html[data-theme="dark"] .diff-col pre {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .secret-box {
    background: #0f172a !important;
    color: #cbd5e1 !important;
}

/* 二维码需要保持白底才能被扫描 */
html[data-theme="dark"] .qr-box {
    background: #ffffff !important;
}

/* ---------------- 文本与辅助色 ---------------- */
html[data-theme="dark"] .username,
html[data-theme="dark"] .session-timer,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .tip,
html[data-theme="dark"] .time-help,
html[data-theme="dark"] .axis,
html[data-theme="dark"] .legend,
html[data-theme="dark"] .detail-label,
html[data-theme="dark"] .entry-info,
html[data-theme="dark"] .version-info,
html[data-theme="dark"] .note,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .status-filter,
html[data-theme="dark"] .pagination,
html[data-theme="dark"] .field label,
html[data-theme="dark"] .card small,
html[data-theme="dark"] .diff-col h4,
html[data-theme="dark"] .steps,
html[data-theme="dark"] label {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .card p,
html[data-theme="dark"] .entry-group-title {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .ev-link,
html[data-theme="dark"] .link {
    color: #60a5fa !important;
}

html[data-theme="dark"] .positive,
html[data-theme="dark"] .pos,
html[data-theme="dark"] .ok {
    color: #34d399 !important;
}

html[data-theme="dark"] .negative,
html[data-theme="dark"] .neg {
    color: #f87171 !important;
}

/* ---------------- 表格 ---------------- */
/* 基准方高亮行（亮色沿用原浅黄） */
tr.ref-row {
    background: #fef3c7;
}

html[data-theme="dark"] table {
    color: #e2e8f0;
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
    border-bottom-color: #334155 !important;
}

html[data-theme="dark"] th {
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] tbody tr:hover {
    background: #1e293b !important;
}

/* 基准方高亮行（浅黄在暗色下改为深琥珀） */
html[data-theme="dark"] tr.ref-row {
    background: #422006 !important;
}

html[data-theme="dark"] tr.ref-row td {
    color: #fde68a !important;
}

html[data-theme="dark"] tr.ref-row .positive {
    color: #6ee7b7 !important;
}

html[data-theme="dark"] tr.ref-row .negative {
    color: #fca5a5 !important;
}

/* ---------------- 表单控件 ---------------- */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #64748b !important;
}

html[data-theme="dark"] .pager button,
html[data-theme="dark"] .pagination button {
    background: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .pager button:disabled,
html[data-theme="dark"] .pagination button:disabled {
    opacity: 0.4;
}

/* ---------------- 状态徽章 ---------------- */
html[data-theme="dark"] .badge {
    background: rgba(59, 130, 246, 0.18) !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] .badge-draft,
html[data-theme="dark"] .badge-imported {
    background: rgba(99, 102, 241, 0.2) !important;
    color: #a5b4fc !important;
}

html[data-theme="dark"] .badge-entered,
html[data-theme="dark"] .badge-active,
html[data-theme="dark"] .badge-reversed,
html[data-theme="dark"] .badge-rev {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}

html[data-theme="dark"] .badge-passed,
html[data-theme="dark"] .badge-confirmed,
html[data-theme="dark"] .badge-published {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}

html[data-theme="dark"] .badge-failed {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

html[data-theme="dark"] .badge-cancelled,
html[data-theme="dark"] .badge-disabled {
    background: rgba(148, 163, 184, 0.2) !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .badge-participant {
    background: rgba(59, 130, 246, 0.18) !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] .badge-reference {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}

html[data-theme="dark"] .badge-system {
    background: rgba(99, 102, 241, 0.2) !important;
    color: #a5b4fc !important;
}

html[data-theme="dark"] .badge-deleted {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

/* ---------------- 提示 / 预检 / 汇总区块 ---------------- */
html[data-theme="dark"] .error,
html[data-theme="dark"] .warning-box,
html[data-theme="dark"] .preflight-error,
html[data-theme="dark"] .check-error,
html[data-theme="dark"] .recon-bad,
html[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.14) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

html[data-theme="dark"] .preflight-pass,
html[data-theme="dark"] .check-pass,
html[data-theme="dark"] .recon-ok,
html[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.14) !important;
    color: #6ee7b7 !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
}

html[data-theme="dark"] .preflight-warning,
html[data-theme="dark"] .check-warning,
html[data-theme="dark"] .warning,
html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .preview-summary {
    background: rgba(245, 158, 11, 0.14) !important;
    color: #fcd34d !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
}

html[data-theme="dark"] .sum-box {
    background: rgba(14, 165, 233, 0.14) !important;
    color: #7dd3fc !important;
    border-left-color: #0ea5e9 !important;
}

html[data-theme="dark"] .diff-changed {
    background: rgba(245, 158, 11, 0.28) !important;
    color: #fcd34d !important;
}

html[data-theme="dark"] .trend {
    border-bottom-color: #334155 !important;
}

/* ---------------- 暗黑模式 / 字段别名 图标按钮 ---------------- */
.theme-toggle {
    background: #e2e8f0;
    color: #334155;
    border: none;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: #cbd5e1;
}

html[data-theme="dark"] .theme-toggle {
    background: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: #475569;
}

.theme-toggle-floating {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ---------------- 字段别名弹窗 ---------------- */
html[data-theme="dark"] .fa-box {
    background: #1e293b !important;
}

html[data-theme="dark"] .fa-title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .fa-desc,
html[data-theme="dark"] .fa-label {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .fa-status {
    background: #0f172a !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .fa-status.fa-status-ok {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #6ee7b7 !important;
}

html[data-theme="dark"] .fa-list {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .fa-key {
    color: #64748b !important;
}

html[data-theme="dark"] .fa-close {
    background: #334155 !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .fa-btn-ghost {
    background: #334155 !important;
    color: #cbd5e1 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .fa-msg-ok {
    color: #6ee7b7 !important;
}

html[data-theme="dark"] .fa-msg-error {
    color: #fca5a5 !important;
}

/* 各页面内的字段别名入口按钮 */
.alias-pencil {
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #334155;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transition: background 0.2s;
}

.alias-pencil:hover {
    background: #e2e8f0;
}

html[data-theme="dark"] .alias-pencil {
    background: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .alias-pencil:hover {
    background: #475569;
}

/* 区块标题内的紧凑别名按钮 */
.alias-pencil-sm {
    width: 26px;
    height: 26px;
    font-size: 13px;
    margin-left: auto;
}

/* ---------------- 补充覆盖 ---------------- */

/* 会话倒计时进入告警状态时仍需保持红色 */
html[data-theme="dark"] .session-timer.warning {
    color: #f87171 !important;
}

/* 首页统计卡片指标名 */
html[data-theme="dark"] .metric .label {
    color: #94a3b8 !important;
}

/* 首页 / 规则页 / 事件页的会话超时弹窗标题与说明 */
html[data-theme="dark"] .idle-box .title,
html[data-theme="dark"] .idle-warning-box .title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .idle-box .desc,
html[data-theme="dark"] .idle-warning-box .desc {
    color: #94a3b8 !important;
}

/* 账户页删除 / 导入预览 */
html[data-theme="dark"] .preview-box {
    background: #0f172a !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .preview-row {
    border-bottom-color: #334155 !important;
}

html[data-theme="dark"] .preview-label {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .preview-value {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .alert-error {
    background: rgba(239, 68, 68, 0.14) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

/* 分页按钮的选中 / 悬停态保持蓝色高亮 */
html[data-theme="dark"] .pagination button.active {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .pagination button:hover:not(:disabled) {
    border-color: #3b82f6 !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] th.sortable:hover,
html[data-theme="dark"] th.sortable.sorted .sort-arrow {
    color: #60a5fa !important;
}

/* 事件页预检 / 预览块内的嵌套文本 */
html[data-theme="dark"] .warning-box p {
    color: #fca5a5 !important;
}

html[data-theme="dark"] .preview-summary strong {
    color: #fcd34d !important;
}

/* 基准方日报的小统计卡片与面板需要区分层次 */
html[data-theme="dark"] .cards .card {
    background: #0f172a !important;
    border-color: #334155 !important;
}

/* ---------------- 表格状态高亮 ---------------- */
html[data-theme="dark"] .ok {
    background: rgba(16, 185, 129, 0.14) !important;
    color: #6ee7b7 !important;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled {
    opacity: 0.65;
}

/* ---------------- 渠道选择页 ---------------- */
html[data-theme="dark"] .channel-item {
    border-color: #334155 !important;
}

html[data-theme="dark"] .channel-item .name {
    color: #e2e8f0 !important;
}

/* ---------------- 页头渠道切换 ---------------- */
.channel-switch {
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    color: #334155;
    background: #fff;
}

html[data-theme="dark"] .channel-switch {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* ---------------- 规则档位弹窗（rule_tiers.js） ---------------- */
html[data-theme="dark"] #rtBox {
    background: #1e293b !important;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6) !important;
}

html[data-theme="dark"] #rtBox .rt-head,
html[data-theme="dark"] #rtBox .rt-foot {
    border-color: #334155 !important;
}

html[data-theme="dark"] #rtBox .rt-title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] #rtBox .rt-subtitle {
    color: #94a3b8 !important;
}

html[data-theme="dark"] #rtBox .rt-section-title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] #rtBox .rt-add {
    color: #60a5fa !important;
}

html[data-theme="dark"] #rtBox .rt-tag {
    background: #0f172a !important;
    border-color: #475569 !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] #rtStatus {
    background: #0f172a !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] #rtStatus.rt-status-error {
    background: rgba(239, 68, 68, 0.14) !important;
    color: #fca5a5 !important;
}

html[data-theme="dark"] #rtCancel {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
