/* brand-theme.css v3 — 加 dark mode 覆盖
 * 关键修复：dark mode 下 Semi 用浅色文字 + 深色背景 token，跟我们奶油+深字主题相反
 * 解决：在 [theme-mode="dark"] / [data-theme="dark"] / 等所有可能 dark selector 下，强制覆盖 token = warm light
 */

/* ===== 1. Semi blue 全替换为 terra cotta orange（light + dark 都覆盖）===== */
:root,
body[theme-mode="dark"],
body[data-theme="dark"],
[data-theme="dark"],
.dark {
  --semi-blue-0: 255, 247, 237;
  --semi-blue-1: 255, 237, 213;
  --semi-blue-2: 255, 215, 168;
  --semi-blue-3: 255, 185, 109;
  --semi-blue-4: 255, 139,  26;
  --semi-blue-5: 254, 110,   0;
  --semi-blue-6: 240,  81,   0;
  --semi-blue-7: 197,  60,   0;
  --semi-blue-8: 159,  45,   0;
  --semi-blue-9: 126,  42,  12;
}

/* ===== 2. Dark mode 强制翻转：bg/text/fill/border token 全部用 warm light variants ===== */
body[theme-mode="dark"],
body[data-theme="dark"],
[data-theme="dark"],
.semi-always-dark,
html[data-theme="dark"] {
  /* 背景 token：奶油色阶（最浅 → 略深） */
  --semi-color-bg-0: #efe7d8 !important;
  --semi-color-bg-1: #f4ece1 !important;
  --semi-color-bg-2: #f7f1e6 !important;
  --semi-color-bg-3: #faf3eb !important;
  --semi-color-bg-4: #fcf6ee !important;

  /* 文字 token：强制深色（对应 light mode 深灰文字） */
  --semi-color-text-0: rgba(28, 31, 35, 1) !important;
  --semi-color-text-1: rgba(28, 31, 35, 0.8) !important;
  --semi-color-text-2: rgba(28, 31, 35, 0.62) !important;
  --semi-color-text-3: rgba(28, 31, 35, 0.35) !important;

  /* fill/border：奶油变体 */
  --semi-color-fill-0: rgba(60, 30, 10, 0.04) !important;
  --semi-color-fill-1: rgba(60, 30, 10, 0.08) !important;
  --semi-color-fill-2: rgba(60, 30, 10, 0.12) !important;
  --semi-color-border: rgba(60, 30, 10, 0.10) !important;

  /* primary（terra cotta）保持一致 */
  --semi-color-primary: #c53c00 !important;
  --semi-color-primary-hover: #f05100 !important;
  --semi-color-primary-active: #9f2d00 !important;

  /* tertiary 中性色 */
  --semi-color-tertiary: rgba(28, 31, 35, 0.62) !important;
  --semi-color-tertiary-hover: rgba(28, 31, 35, 0.5) !important;
}

/* ===== 3. 字体 ===== */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');
body, .semi-portal {
  font-family: "Instrument Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
               "PingFang SC", "Microsoft YaHei", sans-serif !important;
}

/* ===== 4. 全站背景：奶油 + 角落渐变 + 网格 ===== */
html, body,
body[theme-mode="dark"], body[data-theme="dark"] {
  background-color: #efe7d8 !important;
}
#root, .semi-layout, .semi-layout-content,
.semi-layout-sider, .semi-layout-header {
  background-color: transparent !important;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* v5: 网格透明度降到 0.04 (agent 反馈过载) */
  background-image:
    radial-gradient(ellipse 80% 60% at 0% 0%,    rgba(180, 215, 195, 0.40), transparent 70%),
    radial-gradient(ellipse 80% 60% at 100% 100%, rgba(245, 200, 165, 0.45), transparent 70%),
    linear-gradient(to right,  rgba(60, 30, 10, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(60, 30, 10, 0.04) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

/* ===== 5. shine-text 静态化 ===== */
.shine-text {
  background-image: none !important;
  -webkit-text-fill-color: initial !important;
  color: #c53c00 !important;
  animation: none !important;
}

/* ===== 6. 侧边栏 / 卡片：dark mode 下也要奶油白底 ===== */
.semi-navigation,
.semi-card,
.semi-collapse-item,
.semi-modal-content,
.semi-popover-content,
.semi-table,
.semi-descriptions {
  background-color: rgba(255, 251, 245, 0.6) !important;
  backdrop-filter: blur(8px);
  border-color: rgba(60, 30, 10, 0.06) !important;
}

/* ===== 7. Semi 圆角 ===== */
.semi-button { border-radius: 10px !important; }
.semi-input-wrapper, .semi-textarea-wrapper, .semi-select-selection { border-radius: 10px !important; }
.semi-card, .semi-modal-content, .semi-collapse-item, .semi-popover-content {
  border-radius: 16px !important;
  box-shadow: 0 1px 3px rgba(60, 30, 10, 0.05), 0 4px 16px rgba(60, 30, 10, 0.04) !important;
}
.semi-tag { border-radius: 8px !important; }

/* ===== v6: Tag 文字色修复（dark mode 下色彩 tag 浅文字看不见）===== */
.semi-tag.semi-tag-color-green,
.semi-tag.semi-tag-color-success,
.semi-tag-success {
  color: #006d2c !important;
  background-color: rgba(0, 165, 68, 0.18) !important;
}
.semi-tag.semi-tag-color-purple,
.semi-tag.semi-tag-color-violet {
  color: #5b21b6 !important;
  background-color: rgba(141, 84, 255, 0.15) !important;
}
.semi-tag.semi-tag-color-orange,
.semi-tag.semi-tag-color-warning,
.semi-tag-warning {
  color: #9a4400 !important;
  background-color: rgba(255, 139, 26, 0.18) !important;
}
.semi-tag.semi-tag-color-red,
.semi-tag.semi-tag-color-danger,
.semi-tag-danger {
  color: #9f0712 !important;
  background-color: rgba(251, 44, 54, 0.15) !important;
}
.semi-tag.semi-tag-color-blue,
.semi-tag.semi-tag-color-cyan,
.semi-tag.semi-tag-color-teal {
  color: #1e40af !important;
  background-color: rgba(48, 128, 255, 0.15) !important;
}
.semi-tag.semi-tag-color-pink {
  color: #9d174d !important;
  background-color: rgba(255, 35, 87, 0.12) !important;
}
.semi-tag.semi-tag-color-grey,
.semi-tag.semi-tag-color-white,
.semi-tag.semi-tag-color-light-blue {
  color: rgba(28, 31, 35, 0.85) !important;
  background-color: rgba(60, 30, 10, 0.06) !important;
  border: 1px solid rgba(60, 30, 10, 0.10) !important;
}
.semi-tag.semi-tag-color-yellow,
.semi-tag.semi-tag-color-amber {
  color: #7b3306 !important;
  background-color: rgba(252, 187, 0, 0.18) !important;
}
.semi-tag.semi-tag-color-lime {
  color: #4b7d00 !important;
  background-color: rgba(157, 229, 0, 0.18) !important;
}

/* ===== 8. 顶部 nav（v5: alpha 0.85 防对比度跌破 3:1）===== */
.semi-navigation-horizontal,
.semi-navigation-header,
header > nav,
header {
  background-color: rgba(239, 231, 216, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(60, 30, 10, 0.06) !important;
}

/* ===== 9. Primary CTA ===== */
.semi-button-primary {
  background-color: #c53c00 !important;
  border-color: #c53c00 !important;
  color: #fff !important;
  border-radius: 12px !important;
  padding: 0 20px !important;
  height: 40px !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(197, 60, 0, 0.3) !important;
}
.semi-button-primary:hover {
  background-color: #f05100 !important;
  border-color: #f05100 !important;
}

/* ===== 10. 链接颜色 ===== */
a, .semi-typography a, footer a, .semi-layout-footer a {
  color: #c53c00 !important;
}
a:hover { color: #f05100 !important; }

/* ===== 11. H 标题 ===== */
h1, h2, h3, h4 { font-weight: 700 !important; letter-spacing: -0.02em !important; }

/* ===== 12. 代码块 ===== */
.semi-typography pre, code {
  background-color: rgba(255, 247, 237, 0.7) !important;
  border-radius: 8px !important;
}

/* ===== 13. 隐藏主题切换按钮（dark mode 已被强制 light，按钮无效果，避免 confusing）===== */
button[aria-label*="theme" i],
button[aria-label*="主题"],
button[aria-label*="夜间"],
button[aria-label*="深色"],
button[aria-label*="浅色"],
button[title*="切换主题"],
button[title*="theme" i],
button[title*="夜间"],
button[title*="深色"],
[class*="theme-switch"],
[class*="theme-toggle"],
[class*="ThemeSwitch"],
[class*="ThemeToggle"] {
  display: none !important;
}

/* ===== 14. table 内 primary 按钮改 ghost (agent 反馈防"列表页一片橙") ===== */
.semi-table .semi-button-primary,
.semi-table-row .semi-button-primary,
.semi-form .semi-button-primary[size="small"] {
  background-color: transparent !important;
  border: 1px solid #c53c00 !important;
  color: #c53c00 !important;
  height: 28px !important;
  padding: 0 12px !important;
  box-shadow: none !important;
}
.semi-table .semi-button-primary:hover,
.semi-table-row .semi-button-primary:hover {
  background-color: rgba(197, 60, 0, 0.08) !important;
  color: #c53c00 !important;
}

/* ===== 15. table 行分隔线 (agent: 防奶油底"飘") ===== */
.semi-table-tbody .semi-table-row {
  border-bottom: 1px solid rgba(60, 30, 10, 0.06) !important;
}
.semi-table-thead {
  background-color: rgba(255, 251, 245, 0.4) !important;
  border-bottom: 1px solid rgba(60, 30, 10, 0.10) !important;
}

/* ===== v7: dashboard statistic 旁边空色块隐藏（dark mode bg 翻奶油后浮现的 placeholder/skeleton/empty div）===== */
.semi-statistic-prefix:empty,
.semi-statistic-suffix:empty,
.semi-statistic > div:empty,
.semi-statistic-content > div:empty,
[class*="statistic"] [class*="bg"]:empty,
[class*="statistic"] [class*="placeholder"]:empty,
[class*="statistic"] [class*="skeleton"]:not(.semi-skeleton-active),
[class*="card"] [class*="extra"]:empty,
[class*="number-card"] > div:not([class*="content"]):not([class*="title"]):not([class*="icon"]):empty {
  display: none !important;
  background: transparent !important;
}

/* 兜底：dashboard 卡片里所有非语义性空 div 透明 */
.semi-card-body div:empty:not([class]):not([style]),
.semi-card-body span:empty:not([class]) {
  background: transparent !important;
  display: none !important;
}

/* ===== v8 polish: sidebar / table / form / card hover & focus ===== */

/* --- Sidebar item hover + 选中态左边竖线 --- */
.semi-navigation-vertical .semi-navigation-item,
.semi-navigation-sub-open .semi-navigation-item {
  border-radius: 8px !important;
  margin: 2px 6px !important;
  transition: all 0.15s ease !important;
}
.semi-navigation-vertical .semi-navigation-item:hover {
  background-color: rgba(197, 60, 0, 0.08) !important;
  color: #c53c00 !important;
}
.semi-navigation-vertical .semi-navigation-item-selected,
.semi-navigation-vertical .semi-navigation-item-selected::before {
  background-color: rgba(197, 60, 0, 0.12) !important;
  color: #c53c00 !important;
  position: relative;
}
.semi-navigation-vertical .semi-navigation-item-selected::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #c53c00;
  border-radius: 2px;
  background-color: #c53c00 !important;
}
.semi-navigation-vertical .semi-navigation-item .semi-navigation-item-icon {
  color: inherit !important;
}

/* --- Form input focus terra cotta border --- */
.semi-input-wrapper:focus-within,
.semi-textarea-wrapper:focus-within,
.semi-select-selection:focus-within,
.semi-input-wrapper-focus,
.semi-select-focus {
  border-color: #c53c00 !important;
  box-shadow: 0 0 0 3px rgba(197, 60, 0, 0.12) !important;
}

/* --- Table row hover 浅奶油 --- */
.semi-table-tbody .semi-table-row:hover > .semi-table-row-cell,
.semi-table-tbody .semi-table-row:hover {
  background-color: rgba(197, 60, 0, 0.04) !important;
  transition: background-color 0.12s ease !important;
}

/* --- Card hover 微浮起 (只对可交互卡片) --- */
.semi-card[class*="hover"]:hover,
.semi-card-shadows:hover,
.semi-card-bordered:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(60, 30, 10, 0.08), 0 1px 3px rgba(60, 30, 10, 0.06) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}
.semi-card { transition: transform 0.18s ease, box-shadow 0.18s ease !important; }

/* --- Statistic 数字字号 +20% 字重 +1 档（让数据更突出）--- */
.semi-statistic-content-value,
.semi-statistic .semi-statistic-content-value {
  font-size: 2.2em !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
  color: rgba(28, 31, 35, 0.95) !important;
}
.semi-statistic-title {
  font-size: 0.875em !important;
  color: rgba(28, 31, 35, 0.62) !important;
  font-weight: 500 !important;
}

/* --- Icon 统一 terra cotta（仅限 nav / sidebar / button 内的 icon，不动 logo / brand icon）--- */
.semi-navigation-item-icon svg,
.semi-button:not(.semi-button-primary):not(.semi-button-danger) svg,
.semi-tabs-tab-icon svg {
  color: currentColor !important;
}

/* ===== 16. 移动端关 blur + gradient (agent: 低端安卓掉帧 + 横向溢出) ===== */
@media (max-width: 768px) {
  body::before {
    background-image:
      linear-gradient(to right,  rgba(60, 30, 10, 0.04) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(60, 30, 10, 0.04) 1px, transparent 1px) !important;
    background-size: 24px 24px !important;
  }
  .semi-navigation-horizontal,
  .semi-navigation-header,
  header > nav,
  header,
  .semi-card,
  .semi-modal-content,
  .semi-collapse-item {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background-color: #f4ece1 !important;
  }
  .semi-table {
    overflow-x: auto !important;
  }
}
