/*
 * LLMEval Static Website Styles
 * Monadical-inspired Design System
 */

/* ===== Google Fonts Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&family=Source+Code+Pro:wght@400;500;600&display=swap');

/* ===== CSS Variables ===== */
:root {
  /* Colors */
  --color-primary: #0087B4;
  --color-primary-dark: #00668a;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-bg: #ffffff;
  --color-bg-alt: #f9fafb;
  --color-border: #e5e7eb;
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;

  /* Typography */
  --font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-h1: 3.375rem; /* 54px */
  --font-size-h2: 2rem; /* 32px */
  --font-size-h3: 1.5rem; /* 24px */
  --font-size-body: 1rem;
  --font-size-small: 0.875rem;

  /* Spacing */
  --container-max-width: 1280px;
  --section-padding: 4rem;
  --card-padding: 1.5rem;
  --grid-gap: 2rem;

  /* Components */
  --border-radius-card: 0.5rem;
  --border-radius-button: 0.375rem;
  --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --box-shadow-hover: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Typography ===== */
h1 {
  font-size: 2rem; /* Reduced from 3.375rem (54px) to 2rem (32px) */
  font-weight: 300;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: #1a1a1a;
}

h2 {
  font-size: var(--font-size-h2);
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 0.875rem;
  color: #1a1a1a;
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  color: #1a1a1a;
}

p {
  margin-bottom: 1rem;
  font-size: 18px;
  line-height: 1.6;
  color: #333;
}

small {
  font-size: var(--font-size-small);
  color: var(--color-text-secondary);
}

a {
  color: #0087B4;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1;
  padding: 0;
}

/* ===== Header ===== */
header {
  background-color: var(--color-bg);
  padding: 1.5rem 0;
  margin-bottom: 0.5rem;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.header-title h1 {
  margin-bottom: 0;
}

.header-title h2 {
  margin-bottom: 0;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.logo-link:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.monadical-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
}

.monadical-logo:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.monadical-logo img {
  display: block;
}

.breadcrumb {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-bottom: 0;
}

/* Run page specific title reduction */
.run-page .breadcrumb {
  font-size: 1rem;
}

.breadcrumb-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.breadcrumb-link:hover .breadcrumb {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumb a {
  color: var(--color-text-secondary);
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

.header-meta {
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
}

.date-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.date-link:hover {
  text-decoration: underline;
}

/* ===== Cards ===== */
.card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-card);
  padding: var(--card-padding);
  box-shadow: var(--box-shadow);
  margin-bottom: 2rem;
}

.card-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
  margin-bottom: 0.25rem;
}

/* ===== Filters ===== */
.filters {
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-card);
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-weight: 500;
  font-size: var(--font-size-small);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group input,
.filter-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-button);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 135, 180, 0.1);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--border-radius-button);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
  box-shadow: var(--box-shadow-hover);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-bg-alt);
  border-color: var(--color-text-secondary);
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: var(--font-size-small);
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-small);
}

thead {
  background-color: var(--color-bg-alt);
  border-bottom: 2px solid var(--color-border);
}

th {
  padding: 1rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

/* Run page - main column headers stay horizontal */
.run-page th:nth-child(1),
.run-page th:nth-child(2),
.run-page th:nth-child(3),
.run-page th:nth-child(4) {
  height: auto;
  vertical-align: middle;
  padding: 1rem 0.75rem;
}

.run-page th:nth-child(1) > span,
.run-page th:nth-child(2) > span,
.run-page th:nth-child(3) > span,
.run-page th:nth-child(4) > span {
  writing-mode: horizontal-tb;
  transform: none;
  display: inline;
  font-size: 0.75rem;
}

/* Run page - rotate test column headers only */
.run-page th.test-header {
  height: 150px;
  white-space: nowrap;
  vertical-align: bottom;
  padding: 0.5rem;
}

.run-page th.test-header > span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: inline-block;
  font-size: 0.875rem;
}

/* Run overview page - rotate task column headers */
.run-page th.task-header {
  height: 150px;
  white-space: nowrap;
  vertical-align: bottom;
  padding: 0.5rem;
}

.run-page th.task-header > span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: inline-block;
  font-size: 0.875rem;
}

/* Run page - fixed width columns */
.run-page th:nth-child(1),
.run-page td:nth-child(1) {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.run-page th:nth-child(3),
.run-page td:nth-child(3) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.run-page th:nth-child(4),
.run-page td:nth-child(4) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

/* Test columns and Task columns - fixed narrow width */
.run-page th.test-header,
.run-page td.test-cell {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

/* Run overview page - Task columns narrower like test columns */
.overview-page th.task-header,
.overview-page td.test-cell {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

/* Task detail page - Model column is 2nd, flexible width */
.run-page:not(.overview-page) th:nth-child(2),
.run-page:not(.overview-page) td:nth-child(2) {
  width: auto;
  min-width: 200px;
}

/* Run overview page - Score column is 1st, fit content */
.overview-page th:nth-child(1),
.overview-page td:nth-child(1) {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

/* Run overview page - Model column is 2nd, expanded */
.overview-page th:nth-child(2),
.overview-page td:nth-child(2) {
  width: auto;
  min-width: 300px;
}

/* Root page - Date/Time column (1st) is fit to content */
body:not(.run-page) td:nth-child(1),
body:not(.run-page) th:nth-child(1) {
  width: 1%;
  white-space: nowrap;
}

/* Root page - Models Score column (2nd) is flexible */
body:not(.run-page) td:nth-child(2),
body:not(.run-page) th:nth-child(2) {
  width: auto;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.5rem;
}

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

th.sortable::after {
  content: '↕';
  position: absolute;
  right: 0.5rem;
  opacity: 0.3;
}

th.sortable.sort-asc::after {
  content: '↑';
  opacity: 1;
}

th.sortable.sort-desc::after {
  content: '↓';
  opacity: 1;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.15s ease;
}

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

tbody tr.hidden {
  display: none;
}

td {
  padding: 1rem 0.75rem;
  color: var(--color-text-primary);
}

/* ===== Rotated Headers ===== */
th.rotated {
  height: 150px;
  white-space: nowrap;
  vertical-align: bottom;
  padding: 0;
}

th.rotated > div {
  transform: rotate(-90deg);
  width: 30px;
}

th.rotated > div > span {
  padding: 5px 10px;
}

.test-cell {
  text-align: center;
  font-size: 1.25rem;
  padding: 0.5rem !important;
}

.test-cell a {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 0.25rem;
}

.test-cell a:hover {
  background-color: var(--color-bg-alt);
  text-decoration: none;
}

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.badge-neutral {
  background-color: var(--color-bg-alt);
  color: var(--color-text-secondary);
}

/* ===== Model Lists ===== */
.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.model-tag {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-button);
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.model-tag:hover {
  transform: translateY(-1px);
  box-shadow: var(--box-shadow-hover);
}

.model-name {
  padding: 0.25rem 0.5rem;
  color: var(--color-text-secondary);
  background-color: var(--color-bg-alt);
}

.model-divider {
  color: var(--color-text-muted);
  padding: 0 0.25rem;
}

.model-score {
  padding: 0.25rem 0.5rem;
  font-weight: 500;
}

.model-tag.success {
  border-color: var(--color-success);
}

.model-tag.success .model-score {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.model-tag.success:hover .model-score {
  background-color: rgba(16, 185, 129, 0.15);
}

.model-tag.warning {
  border-color: var(--color-warning);
}

.model-tag.warning .model-score {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.model-tag.warning:hover .model-score {
  background-color: rgba(245, 158, 11, 0.15);
}

.model-tag.error {
  border-color: var(--color-error);
}

.model-tag.error .model-score {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.model-tag.error:hover .model-score {
  background-color: rgba(239, 68, 68, 0.15);
}

/* Tooltip for full model name */
.model-tag[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem;
  background-color: #111827;
  color: white;
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: 0.25rem;
  margin-bottom: 0.25rem;
  z-index: 1000;
  pointer-events: none;
}

/* ===== Summary Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: transparent;
  border: none;
  padding: 1.25rem;
  text-align: center;
}

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

.stat-label {
  font-size: var(--font-size-small);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card.success .stat-value {
  color: var(--color-success);
}

.stat-card.error .stat-value {
  color: var(--color-error);
}

.stat-card.primary .stat-value {
  color: var(--color-primary);
}

/* ===== Test Results ===== */
.test-results {
  display: grid;
  gap: 0.5rem;
}

.test-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background-color: var(--color-bg-alt);
  border-radius: var(--border-radius-button);
}

.test-result .badge {
  flex-shrink: 0;
}

.test-result-name {
  flex: 1;
  font-size: var(--font-size-small);
}

.test-result-link {
  font-size: var(--font-size-small);
}

/* ===== Rank Badge ===== */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background-color: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  font-weight: 700;
  font-size: var(--font-size-small);
}

.rank-badge.rank-1 {
  background-color: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.rank-badge.rank-2 {
  background-color: #e5e7eb;
  border-color: #9ca3af;
  color: #374151;
}

.rank-badge.rank-3 {
  background-color: #fed7aa;
  border-color: #ea580c;
  color: #7c2d12;
}

/* ===== Footer ===== */
footer {
  background-color: #2a2c43;
  color: #f6f6f6;
  padding: 2rem 0;
  margin-top: auto;
  text-align: center;
}

footer p {
  color: #f6f6f6;
  margin-bottom: 0;
}

footer a {
  color: #0086b4;
  font-weight: 500;
  text-decoration: none;
}

footer a:hover {
  color: #00a8e0;
  text-decoration: underline;
}

.footer-logo-link {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.footer-logo-link img {
  display: inline-block;
  vertical-align: middle;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-copy {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* ===== Task Cell Colors ===== */
.task-cell-green {
  background-color: rgba(16, 185, 129, 0.1);
}

.task-cell-green:hover {
  background-color: rgba(16, 185, 129, 0.15);
}

.task-cell-orange {
  background-color: rgba(245, 158, 11, 0.1);
}

.task-cell-orange:hover {
  background-color: rgba(245, 158, 11, 0.15);
}

.task-cell-red {
  background-color: rgba(239, 68, 68, 0.1);
}

.task-cell-red:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

/* Make task cells clickable */
.task-cell-green a,
.task-cell-orange a,
.task-cell-red a {
  display: block;
  padding: 0.75rem;
  color: inherit;
  text-decoration: none;
  width: 100%;
  height: 100%;
}

.task-cell-green a:hover,
.task-cell-orange a:hover,
.task-cell-red a:hover {
  text-decoration: none;
}

/* ===== Utility Classes ===== */
.text-center {
  text-align: center;
}

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

.text-secondary {
  color: var(--color-text-secondary);
}

.text-success {
  color: var(--color-success);
}

.text-error {
  color: var(--color-error);
}

.text-warning {
  color: var(--color-warning);
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-secondary);
}

.empty-state h3 {
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  :root {
    --font-size-h1: 2.25rem; /* 36px */
    --font-size-h2: 1.75rem; /* 28px */
    --font-size-h3: 1.5rem; /* 24px */
    --section-padding: 2rem;
  }

  header .container {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

  .table-wrapper {
    border-radius: var(--border-radius-card);
    border: 1px solid var(--color-border);
  }

  table {
    font-size: 0.75rem;
  }

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

  .model-list {
    gap: 0.25rem;
  }

  .filter-actions {
    flex-direction: column;
    width: 100%;
  }

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  :root {
    --font-size-h1: 1.75rem;
    --font-size-h2: 1.25rem;
    --font-size-h3: 1.125rem;
  }

  .container {
    padding: 0 1rem;
  }

  .card {
    padding: 1rem;
  }

  table {
    font-size: 0.7rem;
  }

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

/* ===== Section Titles ===== */
.section-title {
  font-size: 1.5rem;
  font-weight: 300;
  color: #1a1a1a;
  margin-bottom: 1.5rem;
  margin-top: 2rem;
}

.section-title:first-child {
  margin-top: 0;
}

.section-title code {
  font-family: 'Source Code Pro', 'Courier New', Courier, monospace;
  background-color: var(--color-bg-alt);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 1.25rem;
  font-weight: 400;
}

/* ===== Task Prompt ===== */
.task-prompt {
  margin-bottom: 2rem;
}

.task-prompt-content {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-button);
  padding: 1rem;
  font-family: 'Source Code Pro', 'Courier New', Courier, monospace;
  font-size: var(--font-size-small);
  line-height: 1.6;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* ===== Print Styles ===== */
@media print {
  body {
    background: white;
  }

  header,
  footer,
  .filters {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #000;
  }

  a {
    text-decoration: underline;
  }
}
