/* Analysis Deck — History page styles (light editorial theme).
 * Same class names as the FastAPI bundle so history.js works unchanged.
 */

.history-filters {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-paper);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-right: 4px;
}
.range-btn,
.tf-btn {
  padding: 7px 14px;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.range-btn.active,
.tf-btn.active {
  background: var(--accent-burgundy);
  color: #fff;
  border-color: var(--accent-burgundy);
}
.range-btn:hover:not(.active),
.tf-btn:hover:not(.active) {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* SUMMARY CARDS */
.history-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 20px 32px;
}
@media (max-width: 1100px) { .history-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .history-stats { grid-template-columns: repeat(2, 1fr); } }
.hstat {
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.hstat-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.hstat-value {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}
.hstat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.hstat-buy     .hstat-value { color: var(--accent-green); }
.hstat-sell    .hstat-value { color: var(--accent-red); }
.hstat-wait    .hstat-value { color: var(--accent-amber); }
.hstat-bullish .hstat-value { color: var(--accent-green); }
.hstat-conf    .hstat-value { color: var(--accent-navy); }

/* CHARTS */
.history-charts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 32px 24px;
}
@media (max-width: 1100px) { .history-charts { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-family: 'Be Vietnam Pro', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-burgundy);
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}
.chart-wrap { width: 100%; height: 220px; }

/* DETAIL TABLE */
.history-table-wrap {
  padding: 0 32px 32px;
}
.history-table-wrap h3 {
  font-family: 'Be Vietnam Pro', 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.history-table-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.history-table thead {
  background: var(--bg-soft);
}
.history-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  border-bottom: 1px solid var(--border-soft);
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover { background: var(--bg-soft); }

/* numeric cells — mono font */
.history-table .num-mua,
.history-table .num-ban,
.history-table .num-cho,
.history-table .num-avoid,
.history-table .num-bull,
.history-table .num-conf {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.history-table .num-mua  { color: var(--accent-green); }
.history-table .num-ban  { color: var(--accent-red); }
.history-table .num-cho  { color: var(--accent-amber); }
.history-table .num-avoid { color: var(--accent-gray); }
.history-table .num-bull { color: var(--accent-green); }
.history-table .num-conf { color: var(--accent-navy); }

.history-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* Expandable rows */
.history-row { cursor: pointer; transition: background 0.15s; }
.history-row .expand-cell { width: 32px; text-align: center; }
.history-row .chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}
.history-row.expanded .chevron {
  transform: rotate(90deg);
  color: var(--accent-burgundy);
}
.history-row.expanded {
  background: rgba(124, 45, 18, 0.04);
}

/* Inline TF tabs in each row */
.tf-tabs {
  display: inline-flex;
  gap: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.tf-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-width: 36px;
}
.tf-tab:last-child { border-right: none; }
.tf-tab:hover:not(.active) {
  background: var(--bg-paper);
  color: var(--text-primary);
}
.tf-tab.active {
  background: var(--accent-burgundy);
  color: #fff;
}

/* DETAIL ROW (expanded — symbol chips by action) */
.history-detail-row td.history-detail-cell {
  background: var(--bg-soft);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.history-detail-loading {
  padding: 12px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-section { margin-bottom: 14px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.detail-count {
  display: inline-block;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-left: 4px;
}
.symbol-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.symbol-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 3px;
  border: 1px solid;
  font-size: 12px;
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  transition: transform 0.06s, box-shadow 0.15s;
}
.symbol-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.symbol-chip strong { font-weight: 700; }
.symbol-chip .conf { opacity: 0.75; font-size: 11px; }

.bucket-mua   { color: var(--accent-green); background: rgba(21, 128, 61, 0.08);  border-color: rgba(21, 128, 61, 0.28); }
.bucket-ban   { color: var(--accent-red);   background: rgba(159, 18, 57, 0.08);  border-color: rgba(159, 18, 57, 0.28); }
.bucket-cho   { color: var(--accent-amber); background: rgba(161, 98, 7, 0.08);   border-color: rgba(161, 98, 7, 0.28); }
.bucket-avoid { color: var(--accent-gray);  background: rgba(113, 113, 122, 0.08); border-color: rgba(113, 113, 122, 0.28); }


/* ==========================================================
 * RESPONSIVE — match style.css 3-tier breakpoints
 * ========================================================== */
@media (max-width: 1024px) {
  .history-filters { padding: 12px 20px; gap: 18px; }
  .history-stats { padding: 16px 20px; }
  .history-charts { padding: 0 20px 20px; }
  .history-table-wrap { padding: 0 20px 24px; }
}

@media (max-width: 768px) {
  .history-filters {
    padding: 10px 14px;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-group {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .filter-group label { width: 100%; margin-bottom: 4px; }
  .range-btn, .tf-btn { padding: 6px 10px; font-size: 11px; }

  .history-stats { padding: 14px; gap: 8px; grid-template-columns: 1fr 1fr; }
  .hstat { padding: 12px 14px; }
  .hstat-value { font-size: 22px; }

  .history-charts { padding: 0 14px 18px; gap: 10px; }
  .chart-card { padding: 14px 14px 12px; }
  .chart-wrap { height: 180px; }

  .history-table-wrap { padding: 0 14px 24px; }
  .history-table-wrap h3 { font-size: 16px; }
  .history-table { font-size: 12px; }
  .history-table th { font-size: 10px; padding: 8px 8px; letter-spacing: 0.3px; }
  .history-table td { padding: 8px 8px; font-size: 12px; }

  /* Hide low-priority columns on phone — keep Date, TF tabs, MUA, BÁN, CHỜ */
  .history-table th:nth-child(7),  /* ĐỨNG NGOÀI */
  .history-table td:nth-child(7),
  .history-table th:nth-child(9),  /* Bullish % */
  .history-table td:nth-child(9),
  .history-table th:nth-child(10), /* Tin cậy TB */
  .history-table td:nth-child(10) { display: none; }

  .tf-tab { padding: 3px 7px; font-size: 10px; min-width: 30px; }

  .history-detail-row td.history-detail-cell { padding: 12px 16px; }
  .symbol-chip { padding: 4px 8px; font-size: 11px; }
}

@media (max-width: 480px) {
  .history-stats { padding: 12px 10px; }
  .hstat-value { font-size: 19px; }
  .chart-wrap { height: 150px; }
  .history-table th, .history-table td { padding: 7px 5px; font-size: 11px; }
  .history-table-wrap { padding: 0 10px 20px; }

  /* Hide one more column on tiny screens */
  .history-table th:nth-child(8),  /* Tổng */
  .history-table td:nth-child(8) { display: none; }
}
