/* AGI Rating - Main Styles */
/* Theme: Dark/Light with CSS Custom Properties */

:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a35;
  --bg-card: #1e1e3a;
  --bg-hover: #252545;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #2d2d5a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-glow: rgba(79, 70, 229, 0.2);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, .logo-text, .section-title, .table-title {
  font-family: 'Chakra Petch', sans-serif;
}

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: white;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.1rem;
  transition: var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Hero Section */
.hero {
  padding: 3rem 2rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  max-width: 800px;
  margin: 0 auto;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Main Content */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Filter Bar */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 150px;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select,
.filter-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
  width: 100%;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-input {
  min-width: 250px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.tab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition);
}

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

.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Table */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.table-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-secondary);
}

th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: var(--transition);
  position: relative;
}

th:hover {
  color: var(--accent);
}

th.sorted {
  color: var(--accent);
}

th.sorted::after {
  content: attr(data-sort-dir);
  margin-left: 4px;
  font-size: 0.7rem;
}

td {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td {
  background: var(--bg-hover);
}

/* Model Cell */
.model-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.provider-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.model-info {
  display: flex;
  flex-direction: column;
}

.model-name {
  font-weight: 600;
  color: var(--text-primary);
}

.model-provider {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Score Badges */
.score {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
}

.score-excellent {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.score-good {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.score-average {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.score-below {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.score-na {
  color: var(--text-muted);
}

/* Modal Compare Button */
.modal-compare-btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.modal-compare-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.modal-compare-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Category Tags */
.tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Category Leaders Section */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.leaders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.leader-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}

.leader-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.leader-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--accent);
}

.leader-list {
  list-style: none;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.leader-item:last-child {
  border-bottom: none;
}

.leader-rank {
  width: 24px;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 0.75rem;
}

.leader-rank.rank-1 { background: #fbbf24; color: #1e293b; }
.leader-rank.rank-2 { background: #94a3b8; color: #1e293b; }
.leader-rank.rank-3 { background: #cd7f32; color: #1e293b; }

.leader-model {
  flex: 1;
  font-weight: 500;
}

.leader-score {
  font-weight: 600;
  color: var(--accent);
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  height: 300px;
}

/* Sources */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.source-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.source-icon {
  font-size: 1.5rem;
}

.source-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.source-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Model Detail Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-model-name {
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-model-provider {
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.modal-scores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.modal-score-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.modal-score-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.modal-score-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.modal-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.modal-detail-item {
  display: flex;
  flex-direction: column;
}

.modal-detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-detail-value {
  font-weight: 600;
}

.modal-highlights {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.modal-highlights h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.modal-highlights ul {
  list-style: none;
}

.modal-highlights li {
  padding: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-highlights li::before {
  content: '→ ';
  color: var(--accent);
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.75rem;
}

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

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  .btn {
    flex: 1;
  }
  .compare-grid {
    font-size: 0.8rem;
  }
  .compare-cell, .compare-metric-label {
    padding: 0.5rem;
  }

  .leaders-grid {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .sources-grid {
    grid-template-columns: 1fr;
  }

  .modal-details {
    grid-template-columns: 1fr;
  }

  .compare-bar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .compare-bar-actions {
    width: 100%;
  }

  .compare-btn-compare,
  .compare-btn-clear {
    flex: 1;
  }

  .compare-model-header {
    font-size: 0.75rem;
    flex-direction: column;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.compare-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.compare-bar-models {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  flex-wrap: wrap;
}
.compare-bar-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-primary);
  animation: fadeIn 0.2s ease;
}
.compare-bar-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.2rem;
  line-height: 1;
}
.compare-bar-chip .chip-remove:hover {
  color: var(--danger);
}
.compare-bar-actions {
  display: flex;
  gap: 0.5rem;
}
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover {
  background: var(--accent-hover);
}
.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.compare-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-content {
  padding: 1.5rem;
}
.compare-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.compare-radar-wrap {
  max-width: 600px;
  margin: 2rem auto;
  position: relative;
  z-index: 0;
}
.compare-grid {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.compare-header-cell {
  background: var(--bg-secondary);
  padding: 1rem;
  text-align: center;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
}
.compare-header-cell .provider-badge {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.compare-metric-label {
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.compare-cell {
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  white-space: nowrap;
}
.compare-best {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  font-weight: 700;
}
.compare-checkbox-col {
  width: 40px;
  text-align: center;
  cursor: default;
}
.table-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* Keyboard Shortcuts Hint */
.shortcuts-hint {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  z-index: 50;
}

kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  font-family: monospace;
}
