/* ============================================
   黄金白银现货价格查询小程序 - 样式
   微信小程序风格 · 深色主题
   ============================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #ffffff;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6a;
  --color-up: #ff4757;
  --color-down: #2ed573;
  --color-gold: #ffd700;
  --color-gold-dark: #b8960c;
  --color-silver: #c0c0c0;
  --color-silver-dark: #808080;
  --border-color: #2a2a3e;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ---------- Reset ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: 70px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ---------- 顶部导航 ---------- */
.navbar {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 20px 16px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

.navbar-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-gold), #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- 容器 ---------- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px;
}

/* ---------- 加载状态 ---------- */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 26, 0.9);
  z-index: 999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: var(--text-secondary);
  margin-top: 12px;
  font-size: 14px;
}

/* ---------- 价格卡片 ---------- */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.price-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--border-color);
}

.price-card:active {
  transform: scale(0.98);
}

/* 卡片左侧指示条 */
.card-indicator {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
}

.card-gold .card-indicator {
  background: linear-gradient(180deg, var(--color-gold), var(--color-gold-dark));
}

.card-silver .card-indicator {
  background: linear-gradient(180deg, var(--color-silver), var(--color-silver-dark));
}

/* 卡片头部 */
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-emoji {
  font-size: 18px;
}

.card-name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 卡片价格 */
.card-price {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

/* 卡片的品种主题色 */
.card-gold .card-price { color: var(--color-gold); }
.card-silver .card-price { color: var(--color-silver); }

/* 人民币价格 */
.card-price-cny {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.card-gold .card-price-cny { color: rgba(255, 215, 0, 0.7); }
.card-silver .card-price-cny { color: rgba(192, 192, 192, 0.7); }

/* 涨跌幅 */
.card-change {
  font-size: 14px;
  margin-bottom: 6px;
}

.change-value {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.change-value.up {
  background: rgba(255, 71, 87, 0.15);
  color: var(--color-up);
}

.change-value.down {
  background: rgba(46, 213, 115, 0.15);
  color: var(--color-down);
}

.change-value.flat {
  background: rgba(138, 138, 154, 0.15);
  color: var(--text-secondary);
}

/* 卡片底部 */
.card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- 图表区 ---------- */
.chart-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
}

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

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.chart-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
}

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

/* ---------- 行情详情 ---------- */
.detail-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-color);
}

.detail-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.detail-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.detail-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.detail-row.up .detail-value { color: var(--color-up); }
.detail-row.down .detail-value { color: var(--color-down); }

.detail-cny {
  color: #f0c040 !important;
  font-weight: 700 !important;
}

.risk-tip {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(240, 192, 64, 0.1);
  border: 1px solid rgba(240, 192, 64, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.risk-tip strong {
  color: #f0c040;
}

/* ---------- 底部操作栏 ---------- */
.footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.footer-left {
  font-size: 12px;
  color: var(--text-muted);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0f3460, #16213e);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.refresh-btn:hover {
  background: linear-gradient(135deg, #1a4a7a, #1a2a4e);
}

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

.refresh-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.refresh-icon {
  display: inline-block;
  transition: transform 0.3s;
}

.refresh-btn.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}

/* ---------- 动画 ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.price-card {
  animation: fadeInUp 0.3s ease;
}

.price-card:nth-child(1) { animation-delay: 0s; }
.price-card:nth-child(2) { animation-delay: 0.1s; }
.price-card:nth-child(3) { animation-delay: 0.2s; }

/* 价格闪烁动画 */
@keyframes priceFlash {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

.price-flash {
  animation: priceFlash 0.5s ease;
}

/* ---------- 响应式 ---------- */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
    padding: 20px;
  }

  .cards-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .price-card {
    flex: 1;
    min-width: 180px;
  }

  .detail-content {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 360px) {
  .card-price {
    font-size: 26px;
  }

  .detail-content {
    grid-template-columns: 1fr;
  }
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* ---------- 选中状态 ---------- */
::selection {
  background: rgba(255, 215, 0, 0.3);
  color: #fff;
}
