/* Football Quant System Dashboard Styles */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fa;
  color: #2c3e50;
  line-height: 1.6;
}

/* Navbar */
.navbar {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 32px;
}
.navbar .brand { font-size: 18px; font-weight: 700; color: #e94560; text-decoration: none; }
.navbar .nav-links { display: flex; gap: 20px; }
.navbar .nav-links a { color: #ccc; text-decoration: none; font-size: 14px; transition: color 0.2s; }
.navbar .nav-links a:hover { color: #fff; }
.navbar .nav-auth { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.navbar .nav-auth a { color: #888; text-decoration: none; font-size: 12px; }
.navbar .nav-auth a:hover { color: #fff; }
.navbar .nav-user { color: #4CAF50; font-size: 12px; font-weight: 600; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Typography */
h1 { font-size: 22px; margin-bottom: 20px; }
h2 { font-size: 17px; margin: 20px 0 12px; color: #555; }
h3 { font-size: 14px; margin-bottom: 8px; }
.meta { color: #888; font-size: 13px; margin-bottom: 16px; }

/* Match info bar (import page) */
.match-info-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f5f6f8; border-radius: 8px; padding: 10px 16px;
  margin-bottom: 20px; font-size: 15px;
}
.match-serial { color: #e94560; font-weight: 700; }
.match-teams  { color: #1a1a2e; font-weight: 700; font-size: 16px; }
.match-league { color: #888; font-size: 13px; }
.match-time   { color: #999; font-size: 13px; margin-left: auto; }

/* Match nav (prev/next on detail page) */
.match-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.match-nav-title { font-size: 20px; margin: 0; }
.nav-prev, .nav-next {
  font-size: 13px; color: #1a73e8; text-decoration: none;
  padding: 4px 10px; border: 1px solid #1a73e8; border-radius: 4px;
  white-space: nowrap; transition: all 0.2s;
}
.nav-prev:hover, .nav-next:hover { background: #e8f0fe; }
.nav-disabled { color: #ccc; border-color: #ddd; cursor: default; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-card.highlight { border-left: 4px solid #4CAF50; }
.stat-card.warn { border-left: 4px solid #f39c12; }
.stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

/* Section */
.section { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Filters */
.filters { margin-bottom: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters a {
  padding: 4px 12px; border-radius: 4px; text-decoration: none;
  font-size: 13px; color: #555; background: #eee; transition: background 0.2s;
}
.filters a:hover { background: #ddd; }
.filters a.active { background: #1a1a2e; color: #fff; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: #f8f9fa; padding: 10px 8px; text-align: left; font-weight: 600; color: #666; border-bottom: 2px solid #dee2e6; white-space: nowrap; }
table:not(.mobile-tbl) thead th:first-child,
table:not(.mobile-tbl) thead th:nth-child(2) { display: none; }
tbody td { padding: 9px 8px; border-bottom: 1px solid #eee; }
table:not(.mobile-tbl) tbody tr.main-row td:first-child,
table:not(.mobile-tbl) tbody tr.main-row td:nth-child(2) { display: none; }
tbody tr:hover { background: #f8f9ff; }
td a { color: #1a73e8; text-decoration: none; }
td a:hover { text-decoration: underline; }
.pred-val { font-weight: 600; font-family: "SF Mono", "Fira Code", monospace; color: #1a1a2e; }
.odds-val { font-family: "SF Mono", "Fira Code", monospace; font-weight: 600; color: #e94560; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.hit { background: #d4edda; color: #155724; }
.badge.miss { background: #f8d7da; color: #721c24; }
.badge.pending { background: #fff3cd; color: #856404; }

/* Chart */
.chart-container { max-width: 600px; margin: 0 auto; padding: 16px 0; }

/* Odds Grid */
.odds-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.odds-card { background: #f8f9fa; border-radius: 6px; padding: 12px; }
.odds-table { font-size: 12px; }
.odds-table td { padding: 3px 8px; }
.odds-table td:first-child { width: 60px; }

/* Report */
.report-card { margin-bottom: 12px; padding: 12px; background: #f8f9fa; border-radius: 6px; }
.report-meta { font-size: 12px; color: #888; margin-bottom: 8px; }
.report-text { background: #1e1e1e; color: #d4d4d4; padding: 12px; border-radius: 4px; font-size: 12px; overflow-x: auto; max-height: 400px; overflow-y: auto; white-space: pre-wrap; }
details { margin-top: 8px; }
summary { cursor: pointer; font-size: 13px; color: #1a73e8; }
.error-msg { color: #e74c3c; font-size: 13px; margin-top: 4px; }

/* Back link */
.back-link { display: inline-block; margin-top: 16px; color: #1a73e8; text-decoration: none; font-size: 14px; }

/* Pagination */
.pagination { margin-top: 16px; display: flex; gap: 6px; }
.pagination a { padding: 6px 12px; border-radius: 4px; text-decoration: none; font-size: 13px; background: #eee; color: #555; }
.pagination a.active { background: #1a1a2e; color: #fff; }

/* Rule name */
.rule-name { font-size: 11px; color: #999; font-family: monospace; }

/* Progress Bar */
.progress-section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: none;
}
.progress-section.active { display: block; }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.progress-title { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.progress-count { font-size: 13px; color: #888; }
.progress-current {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.progress-current .action-detail {
  color: #1a73e8;
  margin-left: 6px;
}
.progress-track {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #2196F3);
  border-radius: 4px;
  transition: width 0.4s ease;
  width: 0%;
}
.progress-results {
  display: flex;
  gap: 16px;
  font-size: 12px;
}
.progress-results span { display: flex; align-items: center; gap: 4px; }
.progress-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.progress-dot.ok { background: #4CAF50; }
.progress-dot.retry { background: #f39c12; }
.progress-dot.fail { background: #e74c3c; }
.progress-dot.skip { background: #95a5a6; }

.progress-done {
  text-align: center;
  padding: 16px;
  font-size: 14px;
  color: #4CAF50;
  font-weight: 600;
  display: none;
}
.progress-done.active { display: block; }

/* Import Report Form */
.nav-import { color: #e94560 !important; font-weight: 600; }
.btn-import-sm {
  display: inline-block; padding: 3px 12px; background: #e94560; color: #fff;
  border-radius: 4px; text-decoration: none; font-size: 12px; font-weight: 600;
  transition: background 0.2s;
}
.btn-import-sm:hover { background: #c0392b; text-decoration: none; }
.btn-copy-odds {
  display: inline-block; padding: 3px 10px; background: none; color: #1a73e8;
  border: 1px solid #1a73e8; border-radius: 4px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; margin-left: 4px;
}
.btn-copy-odds:hover { background: #e8f0fe; }
.btn-copy-odds:disabled { opacity: 0.6; cursor: default; }
.btn-cancel {
  display: inline-block; padding: 10px 20px; color: #888; text-decoration: none;
  font-size: 14px; margin-left: 12px;
}
.btn-cancel:hover { color: #555; }
.import-form { background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #1a1a2e; }
.field-hint { font-size: 12px; color: #888; margin-bottom: 8px; }
.form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 14px; background: #fff; color: #2c3e50; cursor: pointer;
}
.form-group select:focus { border-color: #1a73e8; outline: none; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.form-group textarea {
  width: 100%; padding: 14px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  line-height: 1.6; resize: vertical; color: #2c3e50; background: #fafbfc;
}
.form-group textarea:focus { border-color: #1a73e8; outline: none; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); background: #fff; }
.btn-primary {
  padding: 10px 28px; background: #e94560; color: #fff; border: none;
  border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #c0392b; }
.import-error {
  background: #f8d7da; color: #721c24; padding: 12px 16px; border-radius: 6px;
  margin-bottom: 16px; font-size: 13px; border: 1px solid #f5c6cb;
}
.import-warning {
  background: #fff3cd; color: #856404; padding: 12px 16px; border-radius: 6px;
  margin-bottom: 16px; font-size: 13px; border: 1px solid #ffc107;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.btn-clear-analysis {
  padding: 4px 14px; background: none; color: #b71c1c;
  border: 1px solid #b71c1c; border-radius: 4px; font-size: 12px;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-clear-analysis:hover { background: #b71c1c; color: #fff; }
.json-ref {
  background: #1e1e1e; color: #d4d4d4; padding: 16px; border-radius: 6px;
  font-size: 12px; overflow-x: auto; line-height: 1.5;
}

/* Loading spinner */
.loading-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: #888;
}
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid #ddd; border-top-color: #e94560;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Secondary button */
.btn-secondary {
  padding: 10px 28px; background: #6c757d; color: #fff; border: none;
  border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: #5a6268; }

/* Fetch-today bar on matches page */
.fetch-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.fetch-bar .btn-primary { padding: 8px 20px; }
#fetchMsg { font-size: 13px; }
#fetchMsg.msg-success  { color: #2e7d32; }
#fetchMsg.msg-error    { color: #c62828; }
#fetchMsg.msg-cooldown { color: #e65100; }
#fetchProgress { margin-bottom: 12px; }

/* Extraction meta info */
.extraction-meta {
  background: #f0f4f8; padding: 8px 16px; border-radius: 6px;
  font-size: 12px; color: #666; margin-bottom: 16px;
}

/* Manual edit form */
.manual-block { margin-bottom: 24px; }
.manual-block h3 { font-size: 14px; margin-bottom: 8px; color: #1a1a2e; }
.manual-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manual-table th { background: #f8f9fa; padding: 8px 12px; text-align: left; font-weight: 600; color: #666; border-bottom: 2px solid #dee2e6; }
.manual-table td { padding: 6px 12px; border-bottom: 1px solid #eee; }
.manual-table .outcome-label { font-weight: 600; font-family: "SF Mono", "Fira Code", monospace; color: #1a1a2e; }
.pred-input {
  width: 100px; padding: 4px 8px; border: 1px solid #ddd; border-radius: 4px;
  font-size: 13px; font-family: "SF Mono", "Fira Code", monospace;
  text-align: center; transition: border-color 0.2s;
}
.pred-input:focus { border-color: #1a73e8; outline: none; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }

/* EV color coding */
.ev-positive { color: #155724; font-weight: 600; }
.ev-negative { color: #721c24; }
.conf-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.conf-badge.high { background: #d4edda; color: #155724; }
.conf-badge.medium { background: #fff3cd; color: #856404; }
.conf-badge.low { background: #f8d7da; color: #721c24; }

/* Collapsible detail rows */
tr.main-row { cursor: pointer; }
tr.main-row:hover { background: #f0f4ff; }
.expand-icon { display: inline-block; width: 16px; font-size: 10px; color: #999; transition: transform 0.2s; }
.detail-row td { padding: 0; border-bottom: 2px solid #dee2e6; }
.detail-panel {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  padding: 12px 20px; background: #fafbfc; font-size: 13px;
}
.detail-item b { color: #666; font-weight: 600; margin-right: 4px; }

/* Chart layout on total-goals page */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; overflow: hidden; }
.chart-box { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-width: 0; overflow: hidden; }
.chart-box h3 { font-size: 14px; color: #555; margin: 0 0 8px; }
.chart-box canvas { max-height: 280px; max-width: 100%; }

/* ====== Mobile Responsive ====== */
.mobile-tbl { display: none; }

@media (max-width: 1024px) {
  .navbar { padding: 0 12px; height: auto; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .navbar .brand { font-size: 16px; }
  .nav-links { display: flex; flex-wrap: nowrap; gap: 12px; }
  .nav-links a { font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .container { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 8px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
  .charts-row { grid-template-columns: 1fr; gap: 12px; overflow: hidden; }
  .chart-box { min-width: 0; overflow: hidden; }
  .chart-box canvas { max-height: 220px; max-width: 100%; }
  .filters { gap: 4px; }
  .filters a { font-size: 11px; padding: 3px 8px; }
  .match-info-bar { font-size: 13px; gap: 6px; padding: 8px 12px; }
  .match-time { margin-left: 0; }
  .section { padding: 12px; }
  .pagination a { padding: 4px 8px; font-size: 12px; }
  .odds-grid { grid-template-columns: 1fr; }
  .detail-panel { flex-direction: column; gap: 4px; padding: 8px 12px; }

  .mobile-tbl { display: table; width: 100%; border-collapse: separate; border-spacing: 0 6px; }
  .mobile-tbl thead th { font-size: 13px; color: #1a1a2e; font-weight: 700; padding: 8px 6px 10px; white-space: nowrap; border-bottom: 1px solid #eee; text-align: left; background: #fff; }
  .mobile-tbl thead th:first-child { padding-left: 8px; }
  .mobile-tbl .tc { text-align: center; }
  .mobile-tbl .tr { text-align: right; }
  .mobile-tbl .m-row { cursor: pointer; background: #fff; }
  .mobile-tbl .m-row td { padding: 8px 6px; border-top: 1px solid #eee; border-bottom: 1px solid #eee; white-space: nowrap; }
  .mobile-tbl .m-row td:first-child { border-radius: 6px 0 0 6px; padding-left: 8px; }
  .m-border-hit td:first-child { border-left: 3px solid #e8e8e8; }
  .m-border-miss td:first-child { border-left: 3px solid #f0f0f0; }
  .m-border-pending td:first-child { border-left: 3px solid #4CAF50; }
  .mobile-tbl .m-row td:last-child { border-radius: 0 6px 6px 0; padding-right: 10px; }
  .mobile-tbl .m-date { font-size: 13px; font-weight: 600; color: #1a1a2e; }
  .mobile-tbl .m-serial { font-size: 13px; color: #e94560; }
  .mobile-tbl .m-teams { font-size: 12px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-tbl .m-opt { font-size: 12px; color: #e94560; font-weight: 500; text-align: center; }
  .mobile-tbl .m-profit { font-size: 13px; font-weight: 600; text-align: right; }
  .mobile-tbl .m-detail td { padding: 0; }
  .m-detail-card { margin: 0 6px 6px; padding: 10px 12px; background: #f8f9fb; border-radius: 0 0 8px 8px; border: 1px solid #e8e8e8; }
  .m-detail-card .md-item { display: flex; justify-content: space-between; padding: 2px 0; font-size: 12px; }
  .m-detail-card .md-item span:first-child { color: #888; }
  .m-detail-card .md-item span:last-child { font-weight: 600; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card { padding: 10px 6px; }
  .stat-value { font-size: 18px; }
  h1 { font-size: 18px; }
  h2 { font-size: 15px; }
  .import-form { padding: 16px; }
  .form-group textarea { font-size: 16px; }
  .btn-primary { width: 100%; }
  .fetch-bar { flex-wrap: wrap; }
}
