/* =========================================================
   COMMON UI – LIGHT + DARK TERMINAL THEME
   ========================================================= */

/* ---------- CSS VARIABLES ---------- */
:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --text: #111;
  --muted: #666;
  --grid: #e5e5e5;
  --header-bg: linear-gradient(180deg, #f5f7fa, #e9edf2);
  --header-border: #cfd6de;
  --row-hover: #eef6ff;
  --accent: #007acc;
}

/* ---------- DARK TERMINAL ---------- */
body.dark {
  --bg: #0e1117;
  --panel: #161b22;
  --text: #e6edf3;
  --muted: #9da7b3;
  --grid: #2b313a;
  --header-bg: linear-gradient(180deg, #1f2933, #161b22);
  --header-border: #30363d;
  --row-hover: #1f2a36;
  --accent: #58a6ff;
}

/* ---------- Base ---------- */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Table ---------- */
table {
  border-collapse: collapse;
  width: max-content;
  font-size: 13px;
  background: var(--panel);
}

th, td {
  padding: 6px 8px;
  border-left: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
  border-top: none;
  border-bottom: none;
  background: var(--panel);
  color: var(--text);
  transition:
    background-color 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

/* ---------- Header ---------- */
th {
  background: var(--header-bg);
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
  cursor: pointer;
  z-index: 5;
  border-bottom: 2px solid var(--header-border);
  letter-spacing: 0.3px;
}

th:hover {
  background: linear-gradient(180deg, var(--accent), transparent);
}

/* ---------- Sticky Symbol ---------- */
th.symbol-col,
td.symbol-col {
  position: sticky;
  left: 0;
  z-index: 6;
  font-weight: bold;
  background: var(--panel);
}

/* ---------- Alignment ---------- */
td.text { text-align: left; }
td.num  { text-align: right; }

/* ---------- Heat colors ---------- */
.green  { background: rgba(46, 204, 113, 0.25) !important; }
.red    { background: rgba(231, 76, 60, 0.25) !important; }
.orange { background: rgba(243, 156, 18, 0.25) !important; }

td.red { font-weight: bold; }

/* ---------- Row hover (entire row) ---------- */
tbody tr:hover td {
  background: var(--row-hover) !important;
}

/* ---------- Keyboard selection ---------- */
tr.kb-selected td {
  outline: 2px solid var(--accent);
  background: rgba(88,166,255,0.15) !important;
}

/* ---------- Sector separator ---------- */
tr.sector-break td {
  border-top: 2px solid var(--header-border) !important;
}

/* ---------- Containers ---------- */
.content {
  height: calc(100vh - 60px);
  overflow: auto;
  padding: 8px;
}

/* ---------- Update time ---------- */
.update-time {
  position: fixed;
  top: 6px;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  z-index: 999;
}

/* ---------- Links ---------- */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- LOADING INDICATOR ---------- */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: var(--muted);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--grid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- PERFORMANCE OPTIMIZATIONS ---------- */
table {
  will-change: transform;
  contain: layout style;
}

tbody tr {
  will-change: transform, box-shadow;
}

/* GPU acceleration for smooth scrolling */
.content {
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Reduce paint on hover - simpler effect */
tbody tr:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ---------- MOBILE RESPONSIVE ---------- */
@media (max-width: 768px) {
  /* Larger touch targets */
  th, td {
    padding: 10px 6px;
    font-size: 12px;
  }
  
  /* Prevent text from being too small */
  table {
    font-size: 12px;
  }
  
  /* Sticky header improvements */
  th {
    white-space: nowrap;
  }
  
  /* Better row selection for touch */
  tbody tr:active td {
    background: var(--row-hover) !important;
  }
  
  .update-time {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  th, td {
    padding: 8px 4px;
    font-size: 11px;
  }
  
  .update-time {
    font-size: 9px;
    right: 5px;
  }
}
