/* 主题变量定义 */
:root {
  /* 默认dark模式 */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-card: #1e2a3a;
  --bg-input: #2d3748;
  --text-primary: #f0f0f0;
  --text-secondary: #c0c0c0;
  --text-muted: #999999;
  --border-color: #2d3748;
  --border-light: #374151;
  --accent-color: #4299e1;
  --accent-hover: #3182ce;
  --success-color: #48bb78;
  --success-hover: #38a169;
  --warning-color: #ed8936;
  --warning-hover: #dd6b20;
  --danger-color: #fc8181;
  --danger-hover: #f56565;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
  --sidebar-bg: #0f172a;
  --sidebar-text: rgba(255, 255, 255, 0.65);
  --sidebar-text-hover: #ffffff;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active: rgba(255, 255, 255, 0.15);
  --sidebar-sub-bg: rgba(0, 0, 0, 0.15);
  --sidebar-sub-item: rgba(255, 255, 255, 0.55);
  --sidebar-sub-item-hover: #ffffff;
  --sidebar-sub-item-hover-bg: rgba(255, 255, 255, 0.04);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --topbar-bg: #0f172a;
  --topbar-text: rgba(255, 255, 255, 0.75);
  --topbar-text-hover: #ffffff;
  --topbar-btn-border: rgba(255, 255, 255, 0.25);
  --topbar-btn-border-hover: rgba(255, 255, 255, 0.6);
  --theme-switch-border: rgba(255, 255, 255, 0.25);
  --theme-switch-border-hover: rgba(255, 255, 255, 0.6);
  --theme-switch-text-hover: #ffffff;
  --table-header-bg: #1e2a3a;
  --table-row-hover: #2d3748;
  --tab-bg: #1e2a3a;
  --tab-active-bg: #2d3748;
  --tab-border: #374151;
}

[data-theme="light"] {
  --bg-primary: #e9eef5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f2f5f9;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text-primary: #343a46;
  --text-secondary: #5c6675;
  --text-muted: #8791a1;
  --border-color: #d4dae3;
  --border-light: #e3e8ef;
  --accent-color: #1a73e8;
  --accent-hover: #1557b0;
  --success-color: #27ae60;
  --success-hover: #219a52;
  --warning-color: #e67e22;
  --warning-hover: #d35400;
  --danger-color: #e74c3c;
  --danger-hover: #c0392b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 22px rgba(15, 23, 42, 0.12);
  --sidebar-bg: #f7f9fc;
  --sidebar-text: #4a5364;
  --sidebar-text-hover: #1a73e8;
  --sidebar-text-active: #1a73e8;
  --sidebar-hover: #e8edf4;
  --sidebar-active: #e1eaf8;
  --sidebar-sub-bg: #eef2f7;
  --sidebar-sub-item: #5c6675;
  --sidebar-sub-item-hover: #1a73e8;
  --sidebar-sub-item-hover-bg: #e1eaf8;
  --sidebar-border: #dfe4ec;
  --topbar-bg: #ffffff;
  --topbar-text: #4a5364;
  --topbar-text-hover: #1a73e8;
  --topbar-btn-border: #d4dae3;
  --topbar-btn-border-hover: #1a73e8;
  --theme-switch-border: #d4dae3;
  --theme-switch-border-hover: #1a73e8;
  --theme-switch-text-hover: #1a73e8;
  --table-header-bg: #f0f3f8;
  --table-row-hover: #eef4fd;
  --tab-bg: #eff2f7;
  --tab-active-bg: #ffffff;
  --tab-border: #dde3eb;
}

/* 跟随系统主题 */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: #1e2a3a;
    --bg-input: #2d3748;
    --text-primary: #f0f0f0;
    --text-secondary: #c0c0c0;
    --text-muted: #999999;
    --border-color: #2d3748;
    --border-light: #374151;
    --accent-color: #4299e1;
    --accent-hover: #3182ce;
    --success-color: #48bb78;
    --success-hover: #38a169;
    --warning-color: #ed8936;
    --warning-hover: #dd6b20;
    --danger-color: #fc8181;
    --danger-hover: #f56565;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    --sidebar-bg: #0f172a;
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(255, 255, 255, 0.15);
    --topbar-bg: #0f172a;
    --topbar-text: rgba(255, 255, 255, 0.75);
    --table-header-bg: #1e2a3a;
    --table-row-hover: #2d3748;
    --tab-bg: #1e2a3a;
    --tab-active-bg: #2d3748;
    --tab-border: #374151;
  }
}

@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    --bg-primary: #e9eef5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f2f5f9;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #343a46;
    --text-secondary: #5c6675;
    --text-muted: #8791a1;
    --border-color: #d4dae3;
    --border-light: #e3e8ef;
    --accent-color: #1a73e8;
    --accent-hover: #1557b0;
    --success-color: #27ae60;
    --success-hover: #219a52;
    --warning-color: #e67e22;
    --warning-hover: #d35400;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 8px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 22px rgba(15, 23, 42, 0.12);
    --sidebar-bg: #f7f9fc;
    --sidebar-text: #4a5364;
    --sidebar-text-hover: #1a73e8;
    --sidebar-text-active: #1a73e8;
    --sidebar-hover: #e8edf4;
    --sidebar-active: #e1eaf8;
    --sidebar-sub-bg: #eef2f7;
    --sidebar-sub-item: #5c6675;
    --sidebar-sub-item-hover: #1a73e8;
    --sidebar-sub-item-hover-bg: #e1eaf8;
    --sidebar-border: #dfe4ec;
    --topbar-bg: #ffffff;
    --topbar-text: #4a5364;
    --topbar-text-hover: #1a73e8;
    --topbar-btn-border: #d4dae3;
    --topbar-btn-border-hover: #1a73e8;
    --theme-switch-border: #d4dae3;
    --theme-switch-border-hover: #1a73e8;
    --theme-switch-text-hover: #1a73e8;
    --table-header-bg: #f0f3f8;
    --table-row-hover: #eef4fd;
    --tab-bg: #eff2f7;
    --tab-active-bg: #ffffff;
    --tab-border: #dde3eb;
  }
}

/* 主题切换器样式 */
.theme-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.theme-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--theme-switch-border);
  border-radius: 4px;
  color: var(--topbar-text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.theme-switcher-toggle:hover {
  border-color: var(--theme-switch-border-hover);
  color: var(--theme-switch-text-hover);
}

.theme-switcher-toggle .theme-icon {
  font-size: 16px;
}

.theme-switcher-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 160px;
  display: none;
}

.theme-switcher-dropdown.show {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.theme-option:hover {
  background: var(--bg-tertiary);
}

.theme-option:first-child {
  border-radius: 6px 6px 0 0;
}

.theme-option:last-child {
  border-radius: 0 0 6px 6px;
}

.theme-option.active {
  color: var(--accent-color);
  background: var(--bg-tertiary);
}

.theme-option .theme-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.theme-option .theme-label {
  flex: 1;
}

.theme-option .theme-check {
  color: var(--accent-color);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.theme-option.active .theme-check {
  opacity: 1;
}

.version-info {
  font-size: small;
  margin-right: 10px;
  opacity: 0.7;
  color: var(--topbar-text);
}

[data-theme="light"] .topbar {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.07);
}

[data-theme="light"] .sidebar {
  border-top: none;
  border-right: 1px solid var(--sidebar-border);
}

@media (prefers-color-scheme: light) {
  [data-theme="system"] .topbar {
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.07);
  }

  [data-theme="system"] .sidebar {
    border-top: none;
    border-right: 1px solid var(--sidebar-border);
  }
}
