/* Temporary grayscale filter - remove when no longer needed */
html {
  filter: grayscale(100%);
}

/* Reset and base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --hover: #f1f5f9;
  --success: #22c55e;
  --warning: #eab308;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC",
    "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1rem;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

#site-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.lang-toggle {
  display: flex;
}

.lang-toggle button {
  padding: 0.4rem 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  width: 3rem;
  text-align: center;
}

.lang-toggle button:first-child {
  border-radius: 4px 0 0 4px;
  margin-right: -1px;
}

.lang-toggle button:last-child {
  border-radius: 0 4px 4px 0;
}

.lang-toggle button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.lang-toggle button:hover:not(.active) {
  background: var(--hover);
}

/* Main content */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.filter-group,
.search-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls label {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.controls select,
.controls input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--surface);
}

.controls input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Filter chips */
.filter-group {
  flex-wrap: wrap;
  align-items: flex-start;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Category tags in table cells */
.cell-categories {
  min-width: 140px;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.1rem;
  border-radius: 4px;
  background: var(--hover);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Table container */
.table-container {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

/* Frozen first column (name) */
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}

th:first-child {
  z-index: 2;
  background: var(--bg);
}

th:first-child::after,
td:first-child::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent);
  pointer-events: none;
}

tbody tr:hover td:first-child {
  background: var(--hover);
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: var(--bg);
  position: sticky;
  top: 0;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

th:hover {
  background: var(--hover);
}

th.sortable .sort-icon {
  display: inline-block;
  width: 8px;
  height: 12px;
  margin-right: 6px;
  vertical-align: middle;
  position: relative;
}

th.sortable .sort-icon::before,
th.sortable .sort-icon::after {
  content: "";
  position: absolute;
  left: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

th.sortable .sort-icon::before {
  top: 0;
  border-bottom: 4px solid var(--text-muted);
}

th.sortable .sort-icon::after {
  bottom: 0;
  border-top: 4px solid var(--text-muted);
}

th.sort-asc .sort-icon::before {
  border-bottom-color: var(--primary);
}

th.sort-asc .sort-icon::after {
  border-top-color: var(--border);
}

th.sort-desc .sort-icon::before {
  border-bottom-color: var(--border);
}

th.sort-desc .sort-icon::after {
  border-top-color: var(--primary);
}

/* Header info icon */
.header-text {
  margin-right: 0.25rem;
}

.header-info {
  cursor: help;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.header-info:hover {
  opacity: 1;
  color: var(--primary);
}

th:not(.sortable) {
  cursor: default;
}

th:not(.sortable):hover {
  background: var(--bg);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover {
  background: var(--hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Cell types */
.cell-name {
  font-weight: 500;
  min-width: 150px;
}

.cell-name a {
  color: var(--text);
  text-decoration: none;
}

.cell-name a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-category {
  min-width: 120px;
}

.cell-score {
  text-align: center;
}

.cell-null {
  color: var(--text-muted);
}

/* Boolean cells */
.cell-boolean {
  text-align: center;
}

.bool-yes {
  color: var(--success);
  font-weight: 600;
}

.bool-no {
  color: #ef4444;
  font-weight: 600;
}

/* Level badges */
.cell-level {
  text-align: center;
}

.level-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.85rem;
}

.level-high {
  background: #dcfce7;
  color: #166534;
}

.level-medium {
  background: #fef9c3;
  color: #854d0e;
}

.level-low {
  background: #fee2e2;
  color: #991b1b;
}

/* Sourced data - clickable */
.has-source {
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}

.has-source:hover {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

/* Transparency score badge */
.score-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.85rem;
}

.score-5 {
  background: #dcfce7;
  color: #166534;
}
.score-4 {
  background: #d1fae5;
  color: #047857;
}
.score-3 {
  background: #fef9c3;
  color: #854d0e;
}
.score-2 {
  background: #fed7aa;
  color: #9a3412;
}
.score-1 {
  background: #fecaca;
  color: #991b1b;
}
.score-0 {
  background: #f3f4f6;
  color: #6b7280;
}

/* Table footer */
.table-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0.75rem 1rem;
  max-width: 300px;
  font-size: 0.85rem;
}

.tooltip-content p {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.tooltip-content a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.tooltip-content a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer p {
  margin: 0.5rem 0;
}

footer a {
  color: var(--primary);
}

#disclaimer {
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  #site-subtitle {
    flex: none;
  }

  .controls {
    flex-direction: column;
  }

  .filter-group,
  .search-group {
    width: 100%;
  }

  .controls select,
  .controls input {
    flex: 1;
  }

  th,
  td {
    padding: 0.5rem 0.75rem;
  }

  .table-footer {
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* Loading state */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
