/**
 * Theme CSS - 全局主题样式与 CSS 变量定义
 * 支持浅色/深色主题切换，通过 data-theme 属性控制
 */

/* ==================== CSS 变量定义 ==================== */
:root {
  /* 品牌色 */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* 背景与文字 */
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;

  /* 阴影 */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);

  /* 导航与侧边栏 */
  --navbar-bg: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;

  /* 页脚 */
  --footer-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);

  /* 表单与交互 */
  --input-bg: #ffffff;
  --hover-bg: #f8fafc;

  /* 过渡动画 */
  --transition: all 0.3s ease;
}

/* ==================== 深色主题 ==================== */
[data-theme="dark"] {
  /* 品牌色 */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  /* 背景与文字 */
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --border: #334155;

  /* 阴影 */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);

  /* 导航与侧边栏 */
  --navbar-bg: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;

  /* 页脚 */
  --footer-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);

  /* 表单与交互 */
  --input-bg: #1e293b;
  --hover-bg: #334155;
}

/* ==================== 全局过渡动画 ==================== */
*,
*::before,
*::after {
  transition: background-color 0.3s ease,
              color 0.3s ease,
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}

/* ==================== 基础样式 ==================== */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ==================== 主题切换按钮 ==================== */
.theme-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

/* 主题切换下拉菜单 */
.theme-dropdown {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  min-width: 160px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.theme-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.theme-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.theme-dropdown-item:hover {
  background-color: var(--hover-bg);
}

.theme-dropdown-item.active {
  color: var(--primary);
  font-weight: 600;
}

.theme-dropdown-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ==================== 语言切换下拉菜单 ==================== */
.lang-dropdown {
  position: fixed;
  bottom: 80px;
  right: 80px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  min-width: 140px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.lang-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.lang-dropdown-item:hover {
  background-color: var(--hover-bg);
}

.lang-dropdown-item.active {
  color: var(--primary);
  font-weight: 600;
}

.lang-dropdown-item .flag {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ==================== 通用组件样式 ==================== */

/* 卡片 */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

/* 输入框 */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  transition: var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input::placeholder {
  color: var(--text-light);
}

/* 导航栏 */
.navbar {
  background: var(--navbar-bg);
  color: #ffffff;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

/* 侧边栏 */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--text);
  width: 240px;
  min-height: 100vh;
  padding: 16px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--sidebar-hover);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

/* 页脚 */
.footer {
  background: var(--footer-bg);
  color: var(--text-light);
  padding: 24px;
  text-align: center;
}

/* 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--hover-bg);
  font-weight: 600;
  color: var(--text);
}

.table tr:hover {
  background: var(--hover-bg);
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.tag-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.tag-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 500px;
  width: 90%;
}

/* 加载动画 */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.pagination-item:hover {
  background: var(--hover-bg);
}

.pagination-item.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pagination-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 响应式适配 */
@media (max-width: 768px) {
  .theme-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .theme-dropdown,
  .lang-dropdown {
    right: 16px;
    bottom: 68px;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
  }
}
