/* ==========================================================================
   AI BENCHMARK REALTIME HUB - LIGHT & SNAPPY DESIGN SYSTEM
   Tối ưu hóa hiệu năng cực cao (Zero Lag), loại bỏ hoàn toàn blur gây giật lag.
   Hỗ trợ Chế độ Sáng (Light Mode - Mặc định) và Tối (Dark Mode) siêu mượt.
   ========================================================================== */

:root {
  /* --- LIGHT THEME (MẶC ĐỊNH - SIÊU SÁNG & SẮC NÉT) --- */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-focus: #0284c7;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;
  --accent-rose: #e11d48;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.15s ease-out; /* Tốc độ chuyển động siêu nhanh 0.15s */
}

/* --- DARK THEME (KHI CHUYỂN ĐỔI) --- */
[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-secondary: #111827;
  --bg-card: #151d2f;
  --bg-card-hover: #1c263d;
  --bg-input: #0b0f17;
  --border-subtle: #1e293b;
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #a855f7;
  --accent-rose: #f43f5e;
  
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 50px;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(5, 150, 105, 0.25);
  text-transform: uppercase;
}

.logo-subtitle {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: var(--shadow-card);
}

.btn-outline {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  color: var(--accent-cyan);
}

.btn-theme-toggle {
  padding: 8px 12px;
  font-size: 1rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

/* ==========================================================================
   STAT SUMMARY CARDS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.775rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.stat-icon.cyan { background: rgba(2, 132, 199, 0.1); color: var(--accent-cyan); }
.stat-icon.emerald { background: rgba(5, 150, 105, 0.1); color: var(--accent-emerald); }
.stat-icon.purple { background: rgba(124, 58, 237, 0.1); color: var(--accent-purple); }
.stat-icon.amber { background: rgba(217, 119, 6, 0.1); color: var(--accent-amber); }

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   ANALYTICS & CHARTS SECTION
   ========================================================================== */
.charts-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .charts-section {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.chart-container {
  position: relative;
  height: 250px;
  width: 100%;
}

/* ==========================================================================
   FILTER & SEARCH CONTROLS
   ========================================================================== */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.dropdown-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.select-custom {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.825rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-custom:focus {
  border-color: var(--accent-cyan);
}

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

.pill {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.775rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
}

.pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.pill.active {
  background: rgba(2, 132, 199, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(2, 132, 199, 0.35);
}

/* ==========================================================================
   LEADERBOARD TABLE
   ========================================================================== */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
  margin-bottom: 30px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

/* Riêng cột 2 (Tên Model & Hãng) căn trái để thẳng hàng chữ */
.leaderboard-table th:nth-child(2),
.leaderboard-table td:nth-child(2) {
  text-align: left;
  padding-left: 16px;
}

.leaderboard-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-input);
  user-select: none;
  cursor: pointer;
}

.leaderboard-table th:hover {
  color: var(--accent-cyan);
}

.leaderboard-table td {
  color: var(--text-primary);
  transition: background 0.1s ease;
}

.leaderboard-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.btn-action-view {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease;
}

.btn-action-view:hover {
  background: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
  transform: translateY(-1px);
}

.leaderboard-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.8rem;
}

.rank-1 { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.rank-2 { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.rank-3 { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.rank-other { background: var(--bg-input); color: var(--text-muted); }

.model-name-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.model-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.model-name:hover {
  color: var(--accent-cyan);
}

.model-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 0.72rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 0.685rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.meta-pill-date {
  color: #d97706;
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-open {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.685rem;
  font-weight: 700;
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(5, 150, 105, 0.25);
  white-space: nowrap;
}

.metric-high {
  font-weight: 700;
  color: var(--accent-cyan);
}

.metric-highlight {
  font-weight: 700;
  color: var(--accent-emerald);
}

/* ==========================================================================
   MODAL & PLAYGROUND
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--accent-rose);
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-cyan);
}

.playground-result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  display: none;
}

.result-metrics {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.825rem;
}

.result-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 14px;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--accent-cyan);
}

/* ==========================================================================
   SMART INSTANT FLOATING TOOLTIP & SORTABLE HEADER SYSTEM
   ========================================================================== */
.smart-tooltip {
  position: fixed;
  display: none;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.78rem;
  line-height: 1.45;
  max-width: 290px;
  z-index: 999999;
  pointer-events: none;
  white-space: normal;
  text-transform: none;
  letter-spacing: normal;
  transition: opacity 0.1s ease;
}

.smart-tooltip-title {
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.info-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.65;
  margin-left: 2px;
  transition: all 0.15s ease;
  cursor: help;
  vertical-align: baseline;
  line-height: 1;
}

th.sortable-th:hover .info-tag {
  color: var(--accent-cyan);
  opacity: 1;
  transform: scale(1.2);
}

/* Sortable Headers */
th.sortable-th {
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

th.sortable-th:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

.sort-icon {
  font-size: 0.65rem;
  margin-left: 2px;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

th.sortable-th:hover .sort-icon {
  opacity: 0.8;
}

th.sort-active {
  color: var(--accent-cyan) !important;
}

th.sort-active .sort-icon {
  opacity: 1;
  color: var(--accent-cyan);
}

/* Global Rank Badge */
.global-rank-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(2, 132, 199, 0.2);
  margin-top: 2px;
}


