/* ==========================================================================
   UI LỊCH SỬ SJC (PREMIUM MODERN DASHBOARD DESIGN)
   ========================================================================== */

/* Sub-page container with clean page transition */
.sub-page#sjcHistoryPage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle at 10% 20%, rgba(248, 250, 252, 1) 0%, rgba(241, 245, 249, 0.9) 100%) !important;
  z-index: 1000;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  scrollbar-width: thin;
}

.sub-page#sjcHistoryPage.open {
  transform: translateX(0);
}

/* Scrollbar styling */
.sub-page#sjcHistoryPage::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sub-page#sjcHistoryPage::-webkit-scrollbar-track {
  background: transparent;
}

.sub-page#sjcHistoryPage::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

.sub-page#sjcHistoryPage::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.sjc-hist-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 96px 24px;
  font-family: 'Be Vietnam Pro', -apple-system, sans-serif;
  color: var(--primary-text);
}

/* Header UI */
.sjc-hist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding-bottom: 20px;
}

.sjc-hist-header .sv-btn-home {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 12px;
  cursor: pointer;
  color: #d97706;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  margin-right: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.sjc-hist-header .sv-btn-home:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #b45309;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(148, 163, 184, 0.12);
}

.sjc-hist-title {
  font-size: 1.5rem;
  font-weight: 850;
  color: var(--primary-text);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  letter-spacing: -0.03em;
}

.sjc-hist-title svg {
  color: #fbbf24;
  filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.2));
}

/* Metric Cards Grid */
.sjc-hist-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

@media (min-width: 769px) {
  .sjc-hist-metrics {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
  }
}

.sjc-hist-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 22px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.01), 0 2px 4px -1px rgba(0, 0, 0, 0.005);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

@media (min-width: 769px) {
  .sjc-hist-card {
    padding: 28px 24px;
    border-radius: 24px;
  }
}

.sjc-hist-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 28px -12px rgba(148, 163, 184, 0.28);
  border-color: rgba(203, 213, 225, 0.8);
}

/* Rounded accent left pill */
.sjc-hist-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 4px;
  height: 48px;
  transform: translateY(-50%);
  border-radius: 0 4px 4px 0;
}

/* Premium gradient indicators */
.sjc-hist-card.gold {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.04) 0%, rgba(217, 119, 6, 0.06) 100%);
}
.sjc-hist-card.gold::before {
  background: linear-gradient(to bottom, #fbbf24, #d97706);
}

.sjc-hist-card.gap-card {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.04) 0%, rgba(190, 18, 60, 0.06) 100%);
}
.sjc-hist-card.gap-card::before {
  background: linear-gradient(to bottom, #f43f5e, #be123c);
}

.sjc-hist-card.peak-gold {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, rgba(180, 83, 9, 0.06) 100%);
}
.sjc-hist-card.peak-gold::before {
  background: linear-gradient(to bottom, #f59e0b, #b45309);
}

.sjc-hist-card.peak-gap {
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.04) 0%, rgba(159, 18, 57, 0.06) 100%);
}
.sjc-hist-card.peak-gap::before {
  background: linear-gradient(to bottom, #e11d48, #9f1239);
}

.sjc-card-label {
  font-size: 0.72rem;
  color: var(--secondary-text);
  text-transform: uppercase;
  font-weight: 750;
  margin-bottom: 8px;
  letter-spacing: 0.08em;
}

.sjc-card-val {
  font-size: 1.85rem;
  font-weight: 850;
  color: var(--primary-text);
  margin-bottom: 8px;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

@media (min-width: 769px) {
  .sjc-card-val {
    font-size: 2.15rem;
  }
}

.sjc-card-sub {
  font-size: 0.75rem;
  color: var(--secondary-text);
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sjc-card-sub .up {
  color: #059669;
  font-weight: 700;
}

.sjc-card-sub .down {
  color: #db2777;
  font-weight: 700;
}

/* Chart Container styling */
.sjc-hist-chart-section {
  margin-bottom: 32px;
}

.sjc-hist-chart-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(148, 163, 184, 0.03);
}

.sjc-hist-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.sjc-hist-chart-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.sjc-hist-chart-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background: #fbbf24;
  border-radius: 99px;
  box-shadow: 0 1px 3px rgba(251, 191, 36, 0.3);
}

/* Timeframes iOS Segmented Control style */
.sjc-hist-chart-timeframes {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.sjc-hist-chart-timeframes .time-btn {
  padding: 6px 14px;
  font-size: 0.72rem;
  font-weight: 750;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--secondary-text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sjc-hist-chart-timeframes .time-btn:hover {
  color: var(--primary-text);
}

.sjc-hist-chart-timeframes .time-btn.active {
  background: #ffffff;
  color: var(--primary-text);
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.24);
}

.chart-inner-wrapper {
  position: relative;
  width: 100%;
}

/* Data Table wrapper */
.sjc-hist-table-wrapper {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 20px;
  overflow-x: auto;
  box-shadow: 0 4px 12px rgba(148, 163, 184, 0.02);
  margin-bottom: 24px;
  scrollbar-width: thin;
}

.sjc-hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 800px;
  table-layout: fixed;
}

.sjc-hist-table th {
  background: #f8fafc;
  padding: 16px 20px;
  font-weight: 750;
  color: var(--secondary-text);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  text-align: left;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.sjc-hist-table td {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--primary-text);
  vertical-align: middle;
}

.sjc-hist-table tbody tr {
  transition: background-color 0.2s ease;
}

.sjc-hist-table tbody tr:nth-child(even) {
  background-color: #fafcfd;
}

.sjc-hist-table tbody tr:hover {
  background-color: #f1f5f9;
}

.sjc-hist-table td div {
  font-weight: 650;
  font-size: 0.9rem;
}

/* Custom premium GAP badges */
.sjc-hist-gap-badge {
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  letter-spacing: -0.01em;
}

.sjc-hist-gap-badge.positive {
  background-color: #fff1f2;
  color: #db2777;
  border: 1px solid rgba(251, 207, 232, 0.5);
}

.sjc-hist-gap-badge.negative {
  background-color: #e6fcf5;
  color: #047857;
  border: 1px solid rgba(167, 243, 208, 0.5);
}

/* Spread Column and cell changes indicators */
.sjc-hist-change {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-top: 4px;
}

.sjc-hist-change.up {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid rgba(209, 250, 229, 0.6);
}

.sjc-hist-change.down {
  background: #fff5f5;
  color: #e11d48;
  border: 1px solid rgba(254, 226, 226, 0.6);
}

.sjc-hist-change.neutral {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid rgba(226, 232, 240, 0.6);
}

/* Pagination Section */
.sjc-hist-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  margin-top: 12px;
}

.sjc-hist-page-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: #ffffff;
  border-radius: 10px;
  cursor: pointer;
  color: var(--primary-text);
  font-size: 0.8rem;
  font-weight: 750;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.sjc-hist-page-btn:hover:not(:disabled):not(.active) {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.sjc-hist-page-btn.active {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.sjc-hist-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* Mobile responsiveness & Compact layout queries */
@media (max-width: 768px) {
  .sjc-hist-container {
    padding-top: 84px;
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: 64px;
  }

  .sjc-hist-header {
    margin-bottom: 16px;
    padding-bottom: 10px;
  }

  .sjc-hist-header .sv-btn-home {
    width: 36px;
    height: 36px;
    margin-right: 10px;
    border-radius: 10px;
  }

  .sjc-hist-header .sv-btn-home svg {
    width: 16px;
    height: 16px;
  }

  .sjc-hist-title {
    font-size: 1.25rem;
    gap: 8px;
  }

  .sjc-hist-title svg {
    width: 20px;
    height: 20px;
  }

  .sjc-hist-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }

  .sjc-hist-card {
    padding: 16px;
    border-radius: 16px;
  }

  .sjc-card-label {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }

  .sjc-card-val {
    font-size: 1.45rem;
    margin-bottom: 4px;
  }

  .sjc-card-sub {
    font-size: 0.68rem;
  }

  .sjc-hist-chart-card {
    padding: 16px;
    border-radius: 20px;
  }

  .sjc-hist-chart-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .sjc-hist-chart-title {
    font-size: 0.95rem;
  }

  .sjc-hist-chart-timeframes {
    justify-content: space-between;
  }

  .sjc-hist-chart-timeframes .time-btn {
    flex-grow: 1;
    text-align: center;
    padding: 8px 2px;
    font-size: 0.68rem;
  }

  .chart-inner-wrapper {
    height: 320px !important;
  }

  .sjc-hist-table-wrapper {
    border-radius: 16px;
    margin-bottom: 20px;
  }

  .sjc-hist-table {
    font-size: 0.78rem;
  }

  .sjc-hist-table th {
    padding: 12px 10px;
    font-size: 0.7rem;
  }

  .sjc-hist-table td {
    padding: 12px 10px;
    font-size: 0.78rem;
  }

  .sjc-hist-table td div {
    font-size: 0.82rem;
  }

  .sjc-hist-gap-badge {
    padding: 4px 8px;
    font-size: 0.72rem;
    border-radius: 8px;
  }

  .sjc-hist-change {
    padding: 1px 4px;
    font-size: 0.65rem;
    border-radius: 4px;
  }

  .sjc-hist-page-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.75rem;
  }
}