/* ============================================================
   三角洲行动工具站 — 设计系统
   军事战术风 · 深色默认 · 品级色体系
   ============================================================ */

/* ---- CSS 变量（配色系统） ---- */
:root {
  /* 主色调 */
  --bg-primary: #0a0e14;
  --bg-secondary: #111820;
  --bg-card: #151d28;
  --bg-input: #0d1219;
  --border: #1e2a38;
  --border-hover: #2a3a4a;
  
  /* 文字色 */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #555d66;
  
  /* 品级色 — 深色主题 */
  --grade-0: #6e7681;          /* 无品级：中性灰 */
  --grade-1: #c9d1d9;          /* 一级：白/浅灰 */
  --grade-2: #3fb950;          /* 二级：绿 */
  --grade-3: #58a6ff;          /* 三级：蓝 */
  --grade-4: #bc8cff;          /* 四级：紫 */
  --grade-5: #f0883e;          /* 五级：金/橙 */
  --grade-6: #f85149;          /* 六级：红 */
  
  /* 品级色背景（半透明） */
  --grade-0-bg: rgba(110, 118, 129, 0.15);
  --grade-1-bg: rgba(201, 209, 217, 0.12);
  --grade-2-bg: rgba(63, 185, 80, 0.15);
  --grade-3-bg: rgba(88, 166, 255, 0.15);
  --grade-4-bg: rgba(188, 140, 255, 0.15);
  --grade-5-bg: rgba(240, 136, 62, 0.15);
  --grade-6-bg: rgba(248, 81, 73, 0.15);
  
  /* 功能色 */
  --accent: #f0883e;
  --accent-hover: #f4a261;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  
  /* 涨跌色（游戏交易行惯例：涨绿跌红） */
  --price-up: #3fb950;
  --price-down: #f85149;
  
  /* 估算价标记 */
  --estimated-bg: #e67e22;
  --estimated-text: #fff;
  
  /* 侧边栏 */
  --sidebar-width: 220px;
  --sidebar-bg: #0d1219;
  
  /* 圆角与阴影 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
  
  /* 过渡 */
  --transition: 0.2s ease;
}

/* ---- 浅色主题 ---- */
[data-theme="light"] {
  --bg-primary: #f6f8fa;
  --bg-secondary: #fff;
  --bg-card: #fff;
  --bg-input: #f6f8fa;
  --border: #d0d7de;
  --border-hover: #afb8c1;
  
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  
  /* 品级色 — 浅色主题（加深以保证对比度） */
  --grade-0: #57606a;
  --grade-1: #24292f;
  --grade-2: #1a7f37;
  --grade-3: #0969da;
  --grade-4: #8250df;
  --grade-5: #bc4c00;
  --grade-6: #cf222e;
  
  --grade-0-bg: rgba(87, 96, 106, 0.1);
  --grade-1-bg: rgba(36, 41, 47, 0.08);
  --grade-2-bg: rgba(26, 127, 55, 0.1);
  --grade-3-bg: rgba(9, 105, 218, 0.1);
  --grade-4-bg: rgba(130, 80, 223, 0.1);
  --grade-5-bg: rgba(188, 76, 0, 0.1);
  --grade-6-bg: rgba(207, 34, 46, 0.1);
  
  --accent: #bc4c00;
  --accent-hover: #9e3a00;
  
  --price-up: #1a7f37;
  --price-down: #cf222e;
  
  --sidebar-bg: #f0f3f6;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* ---- 基础重置 ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- 布局 ---- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: block;
}

.sidebar-logo span {
  color: var(--text-primary);
  font-weight: 400;
  font-size: 0.85em;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  font-size: 0.95em;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--grade-5-bg);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 1.1em;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75em;
  color: var(--text-muted);
}

/* 主内容区 */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-width: 0;
}

/* 移动端侧边栏收起 */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.2em;
}

/* ---- 卡片 ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.85em;
  color: var(--text-secondary);
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

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

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

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85em;
}

.btn-block {
  width: 100%;
}

/* ---- 表单 ---- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95em;
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* ---- 表格 ---- */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

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

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
}

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

/* ---- 等宽数字 ---- */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* 价格格式化 */
.price {
  font-weight: 600;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

/* 涨跌色 */
.price-up {
  color: var(--price-up);
}

.price-down {
  color: var(--price-down);
}

.price-flat {
  color: var(--text-muted);
}

/* ---- 品级标签 ---- */
.grade-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8em;
  font-weight: 600;
}

.grade-0 { background: var(--grade-0-bg); color: var(--grade-0); }
.grade-1 { background: var(--grade-1-bg); color: var(--grade-1); }
.grade-2 { background: var(--grade-2-bg); color: var(--grade-2); }
.grade-3 { background: var(--grade-3-bg); color: var(--grade-3); }
.grade-4 { background: var(--grade-4-bg); color: var(--grade-4); }
.grade-5 { background: var(--grade-5-bg); color: var(--grade-5); }
.grade-6 { background: var(--grade-6-bg); color: var(--grade-6); }

/* 品级边框（卡片） */
.grade-border-0 { border-left: 3px solid var(--grade-0); }
.grade-border-1 { border-left: 3px solid var(--grade-1); }
.grade-border-2 { border-left: 3px solid var(--grade-2); }
.grade-border-3 { border-left: 3px solid var(--grade-3); }
.grade-border-4 { border-left: 3px solid var(--grade-4); }
.grade-border-5 { border-left: 3px solid var(--grade-5); }
.grade-border-6 { border-left: 3px solid var(--grade-6); }

/* ---- 估算价标记 ---- */
.est-tag {
  display: inline-block;
  background: var(--estimated-bg);
  color: var(--estimated-text);
  font-size: 0.7em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 600;
}

/* ---- 物品卡片 ---- */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.item-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.item-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.item-card-name {
  font-size: 0.9em;
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card-meta {
  font-size: 0.8em;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* ---- 物品网格 ---- */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* ---- 分页 ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination-btn {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
}

.pagination-btn:hover {
  border-color: var(--accent);
}

.pagination-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

/* ---- 方案卡片 ---- */
.sol-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  border-left: 4px solid var(--accent);
}

.sol-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.sol-title {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05em;
}

.sol-stats {
  font-size: 0.85em;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
}

.sol-stats .value {
  color: var(--success);
  font-weight: 600;
}

.sol-items {
  display: grid;
  gap: 8px;
}

.sol-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.sol-item-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg-card);
  flex-shrink: 0;
}

.sol-item-info {
  flex: 1;
  min-width: 0;
}

.sol-item-name {
  font-size: 0.9em;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sol-item-meta {
  font-size: 0.75em;
  color: var(--text-secondary);
}

.sol-item-price {
  font-weight: 700;
  color: var(--success);
  font-size: 0.95em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- 空状态 ---- */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 0.95em;
}

/* ---- 页脚 ---- */
.footer {
  text-align: center;
  font-size: 0.75em;
  color: var(--text-muted);
  padding: 24px 0;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

/* ---- 筛选栏 ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.filter-bar .form-group {
  margin-bottom: 0;
  min-width: 120px;
}

.filter-bar .form-input,
.filter-bar .form-select {
  padding: 8px 10px;
  font-size: 0.85em;
}

/* ---- 标签页 ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9em;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- 趋势图（内联 SVG） ---- */
.trend-chart {
  width: 100%;
  height: 120px;
}

.trend-chart polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-chart circle {
  fill: var(--accent);
}

.trend-chart .grid-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 4, 4;
}

/* ---- 工具提示 ---- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 1000;
}

.tooltip:hover::after {
  opacity: 1;
}

/* ---- 加载状态 ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .menu-toggle {
    display: block;
  }
  
  .main {
    margin-left: 0;
    padding: 16px;
    padding-top: 56px;
  }
  
  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  
  .filter-bar {
    flex-direction: column;
  }
  
  .filter-bar .form-group {
    width: 100%;
  }
  
  .sol-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .sol-item-img {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 375px) {
  html {
    font-size: 13px;
  }
  
  .item-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .sol-item {
    flex-wrap: wrap;
  }
}

/* ---- 侧边栏遮罩层 ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }
}

/* ---- 地图快速填入按钮组 ---- */
.map-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.map-btn {
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.map-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- 详情模态框 ---- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ---- 枪械槽位 ---- */
.gun-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.gun-slot-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: var(--text-muted);
}

.gun-slot-info {
  flex: 1;
}

.gun-slot-name {
  font-size: 0.9em;
  font-weight: 500;
}

.gun-slot-desc {
  font-size: 0.8em;
  color: var(--text-secondary);
}

.gun-slot-select {
  max-width: 200px;
}

/* ---- 属性条 ---- */
.attr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.attr-label {
  width: 80px;
  font-size: 0.8em;
  color: var(--text-secondary);
  text-align: right;
}

.attr-track {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.attr-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width var(--transition);
}

.attr-value {
  width: 30px;
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
}
