/* 个人的数据分享网站 - 响应式样式 */

/* === CSS Variables === */
:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --secondary: #1d3557;
  --accent: #457b9d;
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #212529;
  --text-secondary: #6c757d;
  --border: #dee2e6;
  --success: #2a9d8f;
  --warning: #f4a261;
  --header-height: 60px;
  --nav-height: 44px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --max-width: 1200px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* === Header === */
.site-header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--accent) 100%);
  color: white;
  padding: 20px 0;
  text-align: center;
}
.logo { font-size: 2rem; font-weight: 700; letter-spacing: 2px; margin-bottom: 4px; }
.tagline { font-size: 0.9rem; opacity: 0.85; }

/* === Navigation === */
.main-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-list { display: flex; justify-content: center; list-style: none; gap: 4px; padding: 8px 0; }
.nav-link {
  display: block;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

/* === Main Content === */
.main-content { padding: 24px 0; min-height: 60vh; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* === Welcome Banner === */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 30px 24px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  text-align: center;
}
.welcome-banner h2 { font-size: 1.5rem; margin-bottom: 8px; }
.welcome-banner p { opacity: 0.9; }

/* === Latest Cards === */
.latest-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.latest-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.latest-card:hover { box-shadow: var(--shadow-hover); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1.1rem; }
.lottery-badge { font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; font-weight: 600; text-transform: uppercase; }
.dlt-badge { background: #e3f2fd; color: #1565c0; }
.qxc-badge { background: #fce4ec; color: #c62828; }
.pls-badge { background: #e8f5e9; color: #2e7d32; }
.plw-badge { background: #fff3e0; color: #e65100; }
.card-body { 
  padding: 16px; 
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}
.latest-draw { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  flex-wrap: wrap; 
  justify-content: center;
  min-height: 60px;
  height: 60px;
}
.draw-label { font-size: 0.85rem; color: var(--text-secondary); }
.draw-num { 
  font-size: 1.3rem; 
  font-weight: 700; 
  color: var(--primary); 
  font-family: "SF Mono", Monaco, monospace;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.latest-info { 
  display: flex; 
  justify-content: space-between;
  gap: 12px; 
  font-size: 0.8rem; 
  color: var(--text-secondary);
  min-height: 20px;
}
.draw-pool { color: var(--success); font-weight: 600; }
.card-footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.btn-refresh {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-refresh:hover { background: var(--primary); color: white; }
.btn-view {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  background: var(--secondary);
  color: white;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-view:hover { background: var(--accent); text-decoration: none; }

/* === Disclaimer === */
.disclaimer-box {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 20px;
}
.disclaimer-box h4 { color: #856404; margin-bottom: 8px; }
.disclaimer-box p { color: #856404; font-size: 0.9rem; }

/* === Page Header === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.4rem; }
.lottery-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.tab-btn:hover, .tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-refresh-all {
  padding: 8px 16px;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-refresh-all:hover { background: var(--accent); }

/* === History Table === */
.history-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.search-box { display: flex; gap: 8px; }
.search-box input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  width: 180px;
}
.btn-search { padding: 8px 16px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; }
.record-count { font-size: 0.85rem; color: var(--text-secondary); }
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); }
.history-table { width: 100%; border-collapse: collapse; background: white; min-width: 700px; }
.history-table th {
  background: var(--secondary);
  color: white;
  padding: 12px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.history-table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.history-table tr:hover td { background: #f1f3f5; }
.draw-numbers { font-family: "SF Mono", Monaco, monospace; font-weight: 700; letter-spacing: 1px; }
.num-ball {
  display: inline-block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  margin: 0 1px;
}
.num-front { background: #e3f2fd; color: #1565c0; }
.num-back { background: #fce4ec; color: #c62828; }
.num-normal { background: #e8f5e9; color: #2e7d32; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Trend === */
.trend-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.trend-controls label { font-size: 0.9rem; }
.trend-controls select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.trend-content { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.trend-chart {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: 400px;
}
.trend-stats {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.trend-stats h4 { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.stat-item { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.9rem; border-bottom: 1px solid #f0f0f0; }
.stat-label { color: var(--text-secondary); }
.stat-value { font-weight: 600; }
.freq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; margin-top: 12px; }
.freq-cell { text-align: center; padding: 8px; border-radius: 4px; font-size: 0.85rem; }
.freq-high { background: #d32f2f; color: white; }
.freq-mid { background: #f57c00; color: white; }
.freq-low { background: #388e3c; color: white; }

/* Canvas for trend charts */
canvas#trendCanvas { width: 100%; height: auto; max-height: 350px; }

/* === Rules === */
.rules-container { display: grid; gap: 16px; }
.rule-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.rule-card h3 { color: var(--primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); }
.rule-content h4 { margin: 12px 0 6px; color: var(--secondary); }
.rule-content p, .rule-content li { font-size: 0.95rem; margin-bottom: 6px; }
.rule-content ul { padding-left: 20px; }

/* === Stats === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.stat-card h4 { color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* === Footer === */
.site-footer { background: var(--secondary); color: rgba(255,255,255,0.8); padding: 24px 0; margin-top: 40px; }
.disclaimer-footer {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.disclaimer-footer h4 { color: #ffc107; margin-bottom: 8px; font-size: 0.95rem; }
.disclaimer-footer p { font-size: 0.85rem; line-height: 1.7; }
.footer-info { 
  text-align: center; 
  font-size: 0.8rem; 
  opacity: 0.7; 
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}
.footer-info a { color: rgba(255,255,255,0.9); }
.footer-item { white-space: nowrap; }
.footer-icp { text-align: center; font-size: 0.8rem; opacity: 0.7; margin-top: 0.3rem; }
.footer-icp a { color: rgba(255,255,255,0.9); }

/* === Utility === */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); font-size: 0.9rem; }
.text-center { text-align: center; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.progress-bar { height: 8px; background: #e9ecef; border-radius: 4px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-fill.odd { background: var(--primary); }
.progress-fill.big { background: var(--accent); }

/* === Toast === */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  z-index: 9999;
  animation: slideIn 0.3s ease;
  max-width: 90vw;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--primary); }
.toast.info { background: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Responsive: Tablet (768px - 1024px) === */
@media (max-width: 1024px) {
  .trend-content { grid-template-columns: 1fr; }
  .trend-chart { min-height: 300px; }
}

/* === Responsive: Mobile (<768px) === */
@media (max-width: 768px) {
  .logo { font-size: 1.5rem; }
  .tagline { font-size: 0.8rem; }
  .nav-list { gap: 2px; }
  .nav-link { padding: 6px 12px; font-size: 0.85rem; }
  .welcome-banner { padding: 20px 16px; }
  .welcome-banner h2 { font-size: 1.2rem; }
  .latest-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .lottery-tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { white-space: nowrap; font-size: 0.8rem; padding: 6px 12px; }
  .history-controls { flex-direction: column; align-items: stretch; }
  .search-box input { flex: 1; }
  .trend-controls { flex-direction: column; align-items: flex-start; }
  .card-footer { flex-direction: row; }
  .draw-num { font-size: 1.1rem; }
  .num-ball { width: 24px; height: 24px; line-height: 24px; font-size: 0.75rem; }
  .history-table { min-width: 600px; font-size: 0.8rem; }
}

/* === Responsive: Small Mobile (<480px) === */
@media (max-width: 480px) {
  .logo { font-size: 1.3rem; letter-spacing: 1px; }
  .nav-link { padding: 5px 8px; font-size: 0.8rem; }
  .btn-refresh, .btn-view { font-size: 0.8rem; padding: 6px 8px; }
  .container { padding: 0 10px; }
}
