/* ============================================================
   川渝好门户 - 统一设计系统 v2.0
   Discuz! X5.0
   ============================================================ */

/* ========== 1. 设计令牌 (Design Tokens) ========== */
:root {
  /* 主色 - 川渝红 */
  --cy-primary: #c41e3a;
  --cy-primary-dark: #a01830;
  --cy-primary-light: #e8445a;
  --cy-primary-bg: #fdf0f2;
  
  /* 辅助色 */
  --cy-gold: #d4a017;
  --cy-orange: #ff6b35;
  --cy-green: #2d8659;
  --cy-blue: #1a6fb5;
  --cy-purple: #7c3aed;
  
  /* 中性色 */
  --cy-gray-50: #f8f9fa;
  --cy-gray-100: #f1f3f5;
  --cy-gray-200: #e9ecef;
  --cy-gray-300: #dee2e6;
  --cy-gray-400: #ced4da;
  --cy-gray-500: #adb5bd;
  --cy-gray-600: #868e96;
  --cy-gray-700: #495057;
  --cy-gray-800: #343a40;
  --cy-gray-900: #212529;
  
  /* 语义色 */
  --cy-success: #2d8659;
  --cy-warning: #f59f00;
  --cy-danger: #e03131;
  --cy-info: #1c7ed6;
  
  /* 背景 */
  --cy-bg: #f5f6f8;
  --cy-bg-card: #ffffff;
  --cy-bg-hover: #f8f9fa;
  
  /* 文字 */
  --cy-text: #212529;
  --cy-text-secondary: #495057;
  --cy-text-muted: #868e96;
  --cy-text-inverse: #ffffff;
  
  /* 边框 */
  --cy-border: #e9ecef;
  --cy-border-dark: #dee2e6;
  
  /* 圆角 */
  --cy-radius-sm: 4px;
  --cy-radius: 8px;
  --cy-radius-lg: 12px;
  --cy-radius-xl: 16px;
  --cy-radius-full: 9999px;
  
  /* 阴影 */
  --cy-shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --cy-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --cy-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --cy-shadow-xl: 0 16px 48px rgba(0,0,0,0.16);
  
  /* 间距 (4px基准) */
  --cy-space-1: 4px;
  --cy-space-2: 8px;
  --cy-space-3: 12px;
  --cy-space-4: 16px;
  --cy-space-5: 20px;
  --cy-space-6: 24px;
  --cy-space-8: 32px;
  --cy-space-10: 40px;
  --cy-space-12: 48px;
  
  /* 字体 */
  --cy-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --cy-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  
  /* 字号 */
  --cy-text-xs: 11px;
  --cy-text-sm: 12px;
  --cy-text-base: 14px;
  --cy-text-lg: 16px;
  --cy-text-xl: 18px;
  --cy-text-2xl: 20px;
  --cy-text-3xl: 24px;
  
  /* 过渡 */
  --cy-transition: all 0.2s ease;
  --cy-transition-slow: all 0.3s ease;
  
  /* 布局 */
  --cy-container: 1200px;
  --cy-header-h: 60px;
  --cy-nav-h: 44px;
}

/* ========== 2. 暗黑模式 ========== */
@media (prefers-color-scheme: dark) {
  :root {
    --cy-bg: #0f1115;
    --cy-bg-card: #1a1d23;
    --cy-bg-hover: #242830;
    --cy-text: #e8eaed;
    --cy-text-secondary: #b0b5bd;
    --cy-text-muted: #6b7280;
    --cy-border: #2a2e36;
    --cy-border-dark: #3a3f48;
    --cy-gray-50: #1a1d23;
    --cy-gray-100: #242830;
    --cy-gray-200: #2a2e36;
  }
}

/* ========== 3. 基础重置 ========== */
* { box-sizing: border-box; }

body {
  font-family: var(--cy-font-sans);
  font-size: var(--cy-text-base);
  line-height: 1.6;
  color: var(--cy-text);
  background: var(--cy-bg);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--cy-primary);
  text-decoration: none;
  transition: var(--cy-transition);
}
a:hover { color: var(--cy-primary-dark); }

img { max-width: 100%; height: auto; }

.wp {
  max-width: var(--cy-container);
  margin: 0 auto;
  padding: 0 var(--cy-space-4);
}

/* ========== 4. 通用组件 ========== */

/* 卡片 */
.cy-card {
  background: var(--cy-bg-card);
  border-radius: var(--cy-radius);
  box-shadow: var(--cy-shadow-sm);
  border: 1px solid var(--cy-border);
  overflow: hidden;
  transition: var(--cy-transition);
}
.cy-card:hover { box-shadow: var(--cy-shadow); }
.cy-card-header {
  padding: var(--cy-space-4) var(--cy-space-5);
  border-bottom: 1px solid var(--cy-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cy-card-title {
  font-size: var(--cy-text-lg);
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--cy-space-2);
}
.cy-card-body { padding: var(--cy-space-5); }

/* 按钮 */
.cy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: var(--cy-text-base);
  font-weight: 500;
  border-radius: var(--cy-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--cy-transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.cy-btn-primary {
  background: var(--cy-primary);
  color: #fff;
  border-color: var(--cy-primary);
}
.cy-btn-primary:hover {
  background: var(--cy-primary-dark);
  border-color: var(--cy-primary-dark);
  color: #fff;
}
.cy-btn-outline {
  background: transparent;
  color: var(--cy-primary);
  border-color: var(--cy-primary);
}
.cy-btn-outline:hover {
  background: var(--cy-primary);
  color: #fff;
}
.cy-btn-ghost {
  background: transparent;
  color: var(--cy-text-secondary);
}
.cy-btn-ghost:hover {
  background: var(--cy-bg-hover);
  color: var(--cy-text);
}
.cy-btn-sm { padding: 4px 12px; font-size: var(--cy-text-sm); }
.cy-btn-lg { padding: 12px 28px; font-size: var(--cy-text-lg); }

/* 标签 */
.cy-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--cy-text-xs);
  font-weight: 600;
  border-radius: var(--cy-radius-full);
  line-height: 1.6;
}
.cy-badge-primary { background: var(--cy-primary-bg); color: var(--cy-primary); }
.cy-badge-success { background: #e6f4ec; color: var(--cy-success); }
.cy-badge-warning { background: #fff4e6; color: var(--cy-warning); }
.cy-badge-danger { background: #ffeaea; color: var(--cy-danger); }
.cy-badge-info { background: #e7f1ff; color: var(--cy-info); }
.cy-badge-gold { background: #fdf3d8; color: var(--cy-gold); }

/* 网格 */
.cy-grid { display: grid; gap: var(--cy-space-4); }
.cy-grid-2 { grid-template-columns: repeat(2, 1fr); }
.cy-grid-3 { grid-template-columns: repeat(3, 1fr); }
.cy-grid-4 { grid-template-columns: repeat(4, 1fr); }
.cy-grid-5 { grid-template-columns: repeat(5, 1fr); }
.cy-grid-6 { grid-template-columns: repeat(6, 1fr); }
.cy-grid-8 { grid-template-columns: repeat(8, 1fr); }

/* 分区标题 */
.cy-section-title {
  display: flex;
  align-items: center;
  gap: var(--cy-space-2);
  font-size: var(--cy-text-xl);
  font-weight: 700;
  margin: 0 0 var(--cy-space-5);
  padding-bottom: var(--cy-space-3);
  border-bottom: 2px solid var(--cy-border);
  position: relative;
}
.cy-section-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 48px;
  height: 2px;
  background: var(--cy-primary);
}
.cy-section-title .more {
  margin-left: auto;
  font-size: var(--cy-text-sm);
  font-weight: 400;
  color: var(--cy-text-muted);
}

/* 空状态 */
.cy-empty {
  text-align: center;
  padding: var(--cy-space-10) var(--cy-space-4);
  color: var(--cy-text-muted);
}
.cy-empty-icon { font-size: 48px; margin-bottom: var(--cy-space-3); opacity: 0.5; }

/* 分隔线 */
.cy-divider {
  height: 1px;
  background: var(--cy-border);
  margin: var(--cy-space-5) 0;
  border: none;
}

/* ========== 5. 工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--cy-text-muted); }
.text-primary { color: var(--cy-primary); }
.text-success { color: var(--cy-success); }
.text-danger { color: var(--cy-danger); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: var(--cy-space-2); }
.mt-4 { margin-top: var(--cy-space-4); }
.mt-6 { margin-top: var(--cy-space-6); }
.mb-2 { margin-bottom: var(--cy-space-2); }
.mb-4 { margin-bottom: var(--cy-space-4); }
.mb-6 { margin-bottom: var(--cy-space-6); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--cy-space-2); }
.gap-3 { gap: var(--cy-space-3); }
.gap-4 { gap: var(--cy-space-4); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ========== 6. 响应式 ========== */
@media (max-width: 1024px) {
  .cy-grid-4, .cy-grid-5, .cy-grid-6, .cy-grid-8 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .cy-grid-2, .cy-grid-3, .cy-grid-4, .cy-grid-5, .cy-grid-6, .cy-grid-8 {
    grid-template-columns: repeat(2, 1fr);
  }
  .wp { padding: 0 var(--cy-space-3); }
}
/* ========== 暗色模式切换按钮样式 ========== */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--cy-gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-right: var(--cy-space-2);
}

.theme-toggle:hover {
  background: var(--cy-gray-200);
  transform: scale(1.05);
}

.theme-icon {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-icon-light {
  opacity: 1;
  transform: scale(1);
}

.theme-icon-dark {
  opacity: 0;
  transform: scale(0.8);
}

body.dark-mode .theme-icon-light {
  opacity: 0;
  transform: scale(0.8);
}

body.dark-mode .theme-icon-dark {
  opacity: 1;
  transform: scale(1);
}

@media (max-width: 480px) {
  .cy-grid-2, .cy-grid-3, .cy-grid-4 { grid-template-columns: 1fr; }
  
  .theme-toggle {
    margin-right: var(--cy-space-1);
    width: 40px;
    height: 40px;
  }
}
