/* ========================================================
   大樂透獨立走勢分布圖專屬樣式 (modules/trend_lotto649/trend_lotto649.css)
   完全隔離作用域 · 標準 01~49 號 ＋ 特別號
   ======================================================== */
:root {
  --bg-primary: #060913;
  --bg-card: #0b1120;
  --bg-header: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --color-brand: #dc2626;
  --color-green: #16a34a;
  --color-gold: #f59e0b;
  --color-yellow: #eab308;
  --border-subtle: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.trend-page-container {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 12px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 頂部導航橫幅 */
.trend-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.4), rgba(15, 23, 42, 0.95));
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(239, 68, 68, 0.15);
}

.trend-brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trend-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(239, 68, 68, 0.6));
}

.trend-title-texts h1 {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff1f2;
  letter-spacing: 0.5px;
}

.trend-badge-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 6px;
  margin-top: 2px;
}

.btn-back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-back-home:hover {
  background: #334155;
  border-color: #ef4444;
  color: #ffffff;
}

/* 頂部操作工具列 */
.trend-toolbar-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.toolbar-group-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pills-group {
  display: flex;
  gap: 6px;
}

.pill-btn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn:hover {
  border-color: #ef4444;
  color: #ffffff;
}

.pill-btn.active {
  background: #dc2626;
  color: #ffffff;
  border-color: #f87171;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.btn-more-periods {
  background: #334155;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-more-periods:hover {
  background: #475569;
}

.toolbar-group-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 3px 8px;
  gap: 6px;
}

.search-input-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 0.82rem;
  width: 155px;
}

.search-input-box input::placeholder {
  color: #64748b;
}

.btn-clear {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1rem;
}

.btn-clear:hover {
  color: #f87171;
}

.tip-hint {
  font-size: 0.75rem;
  color: #eab308;
}

/* 走勢表主體容器 (橫向滾動) */
.trend-table-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.trend-matrix-table {
  table-layout: fixed;
  width: max-content;
  min-width: 1420px;
  border-collapse: collapse;
  margin: 0 auto;
  user-select: none;
}

/* 表頭：【期號】+【01 到 49】紅底白字球號標題列 */
.trend-matrix-table thead th {
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  vertical-align: middle;
}

.trend-matrix-table th.th-period {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  background: #1e293b !important;
  color: #f1f5f9 !important;
  position: sticky;
  left: 0;
  z-index: 5;
}

.trend-matrix-table th.th-ball {
  width: 27px;
  min-width: 27px;
  max-width: 27px;
  background: #dc2626 !important;
  color: #ffffff !important;
  font-family: monospace, sans-serif;
  letter-spacing: -0.5px;
}

/* 表身 */
.trend-matrix-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s;
}

.trend-matrix-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.4);
}

.trend-matrix-table tbody tr:hover {
  background: rgba(51, 65, 85, 0.4);
}

.trend-matrix-table tbody tr.row-active-yellow {
  background: rgba(234, 179, 8, 0.28) !important;
  outline: 1px solid rgba(234, 179, 8, 0.6);
}

.trend-matrix-table tbody tr.row-active-yellow td {
  background: rgba(234, 179, 8, 0.28) !important;
  color: #fef08a !important;
}

.trend-matrix-table tbody td {
  padding: 3px 0;
  height: 28px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  box-sizing: border-box;
}

.trend-matrix-table td.td-period {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background: #0f172a;
  position: sticky;
  left: 0;
  z-index: 3;
}

.trend-matrix-table td.td-cell {
  width: 27px;
  min-width: 27px;
  max-width: 27px;
}

.cell-dash {
  color: rgba(148, 163, 184, 0.25);
  font-size: 10px;
}

/* 正碼球：綠色亮塊 */
.ball-hit-green {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #16a34a;
  color: #ffffff;
  font-weight: 800;
  font-size: 11px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  font-family: monospace;
}

/* 特別號：醒目金底紅外框亮塊 */
.ball-hit-special {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-weight: 900;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #fef08a;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
  font-family: monospace;
}

/* 垂直搜尋高亮欄位 */
.trend-matrix-table .col-active-search {
  background-color: rgba(6, 182, 212, 0.22) !important;
  border-left: 1.5px solid #06b6d4 !important;
  border-right: 1.5px solid #06b6d4 !important;
}

.trend-matrix-table thead th.col-active-search {
  background-color: #0891b2 !important;
  box-shadow: 0 0 8px #06b6d4;
}

/* 表尾統計 */
.trend-matrix-table tfoot th.th-stat-label {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  background: #1e293b !important;
  color: #fbbf24 !important;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  left: 0;
  z-index: 5;
}

.trend-matrix-table tfoot .tfoot-count-row td {
  height: 26px;
  background: #090f1d;
  color: #fef08a;
  font-weight: 800;
  font-size: 11px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: monospace;
}

.trend-matrix-table tfoot .tfoot-bar-row td {
  height: 76px;
  background: #090f1d;
  vertical-align: bottom;
  padding: 0 2px 2px 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bar-wrapper {
  height: 70px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-fill {
  width: 14px;
  background: linear-gradient(180deg, #c084fc 0%, #7e22ce 100%);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 0 6px rgba(168, 85, 247, 0.4);
  transition: height 0.3s ease;
}

/* 底部圖例與說明 */
.trend-footer-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-items {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.swatch.green { background: #16a34a; }
.swatch.gold { background: #f59e0b; border: 1px solid #fef08a; }
.swatch.yellow { background: #eab308; }
.swatch.purple { background: #a855f7; }
