/* ============================================================
   Athletic Lab Performance Testing Dashboard — Static (GitHub Pages)
   Brand: Athletic Lab crimson (#9C1B20), slate (#2D4C62), gold (#C8920D)
   Font: Exo (Google Fonts)
   ============================================================ */

/* ---- CSS variables / theme ---- */
:root,
[data-theme='light'] {
  --crimson: #9C1B20;
  --crimson-dark: #7a1418;
  --slate: #2D4C62;
  --gold: #C8920D;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-alt: #f8f8f6;
  --surface-offset: #f0efed;
  --text: #1a1a18;
  --text-muted: #6b6b68;
  --text-faint: #a0a09d;
  --line: #e2e2df;
  --border: #d4d4d1;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme='dark'] {
  --crimson: #c93a40;
  --crimson-dark: #a52a30;
  --slate: #6a9ab8;
  --gold: #e0a820;
  --bg: #141413;
  --surface: #1e1d1c;
  --surface-alt: #252422;
  --surface-offset: #2a2927;
  --text: #e0dedc;
  --text-muted: #9a9a97;
  --text-faint: #6a6a67;
  --line: #333231;
  --border: #3a3938;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --radius: 8px;
  --radius-sm: 6px;
}

/* ---- reset ---- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Exo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}
img { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
select { font: inherit; color: inherit; }
a { color: var(--crimson); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--crimson);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.print-athlete { display: none; }

.controls { display: flex; align-items: center; gap: 12px; }
.ctl-label { font-size: 13px; font-weight: 500; opacity: 0.85; }
.athlete-select {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 14px;
  min-width: 200px;
  cursor: pointer;
  transition: background 0.18s;
}
.athlete-select:hover { background: rgba(255,255,255,0.2); }
.athlete-select option { color: #1a1a18; background: var(--surface); }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  color: #fff;
  opacity: 0.7;
  transition: opacity 0.18s, background 0.18s;
}
.theme-toggle:hover { opacity: 1; background: rgba(255,255,255,0.15); }

.print-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.18s;
}
.print-btn:hover { background: rgba(255,255,255,0.15); }

/* ---- status line ---- */
.status-line {
  padding: 8px 24px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
}

/* ---- main ---- */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ---- test info section ---- */
.test-info {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.test-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate);
  user-select: none;
  transition: background 0.18s;
}
.test-info-header:hover { background: var(--surface-alt); }
.chevron { transition: transform 0.2s; }
.test-info-header:hover .chevron { transform: rotate(0deg); }
.test-info-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.test-info-body.expanded { max-height: 1200px; }
.test-desc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 0 18px 12px;
}
.test-desc-card {
  padding: 12px 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--crimson);
}
.test-desc-card h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 4px;
}
.test-desc-card p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}
.test-learn-more {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--crimson);
}

/* ---- charts grid ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 920px) {
  .charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 8px;
}
.chart-wrap {
  position: relative;
  height: 300px;
}
.no-data {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 500;
}
.no-data[hidden] { display: none; }

/* ---- table section ---- */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-title {
  background: var(--slate);
  color: #fff;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
}
.table-scroll {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}
#datatable {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}
#datatable th, #datatable td {
  padding: 6px 10px;
  white-space: nowrap;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
#datatable thead th {
  background: var(--surface-offset);
  font-weight: 700;
  font-size: 12px;
  color: var(--slate);
  position: sticky;
  top: 0;
  z-index: 2;
}
#datatable thead th:first-child,
#datatable tbody td:first-child {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 3;
}
#datatable thead th:first-child { z-index: 4; }
#datatable tbody tr:nth-child(even) td { background: var(--surface-alt); }
#datatable tbody tr:nth-child(even) td:first-child { background: var(--surface); }
#datatable td.blank { color: var(--text-faint); }

.footnote {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--surface-alt);
  border-top: 1px solid var(--line);
}

/* ---- footer ---- */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-faint);
}
.footer a { font-weight: 600; }

/* ---- error banner ---- */
.error-banner {
  margin: 24px;
  padding: 16px 18px;
  background: #fde8e8;
  border: 1px solid var(--crimson);
  border-radius: var(--radius);
  color: var(--crimson-dark);
  font-weight: 500;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--slate);
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.login-logo-strip {
  background: var(--crimson);
  padding: 20px 24px;
}
.login-logo { height: 38px; margin: 0 auto; display: block; }
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 22px 32px 6px;
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 32px 22px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 32px 8px;
}
.login-input {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: 'Exo', system-ui, sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  text-align: center;
  letter-spacing: 1px;
}
.login-input:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 2px rgba(156,27,32,0.12);
}
.login-btn {
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--crimson);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}
.login-btn:hover { background: var(--crimson-dark); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-input:disabled { opacity: 0.5; }
.login-error {
  margin: 8px 32px 0;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--crimson-dark);
  background: #fde8e8;
  border-radius: var(--radius-sm);
  text-align: left;
}
.login-status {
  margin: 6px 32px 0;
  font-size: 12px;
  color: var(--text-faint);
}
.login-hint {
  margin: 18px 32px 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: left;
}
.login-hint p { margin-bottom: 6px; }
.login-hint code {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--crimson);
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}
.login-hint strong { color: var(--text); }

/* ---- logout button ---- */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.18s;
}
.logout-btn:hover { background: rgba(255,255,255,0.15); }

/* ---- athlete label (single-athlete mode) ---- */
.athlete-label {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
}

/* ============================================================
   PRINT — landscape, fill the page
   ============================================================ */
@media print {
  @page { size: letter landscape; margin: 0.4in; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  html, body { background: #fff; width: 100%; height: 100%; overflow: hidden; }

  .controls, .status-line, .footnote, .error-banner, .no-data, .footer,
  .test-info, .theme-toggle, .print-btn, .logout-btn, .login-screen { display: none !important; }

  .print-athlete { display: block; font-size: 13px; font-weight: 700; margin-top: 2px; }

  .topbar { padding: 5px 0; box-shadow: none; border-radius: 0; position: static; }
  .logo { height: 28px; }

  main {
    padding: 0;
    max-width: 100% !important;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 50px);
  }

  .charts-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin: 0 0 8px 0;
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
  }
  .chart-card {
    padding: 4px 8px 2px;
    border-radius: var(--radius-sm);
    box-shadow: none;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
  }
  .chart-title { font-size: 10px; margin-bottom: 2px; flex: 0 0 auto; }
  .chart-wrap { height: 100% !important; width: 100%; flex: 1 1 auto; min-height: 0; }
  canvas { max-width: 100% !important; }

  .table-section {
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
    flex: 0 0 auto;
    box-shadow: none;
  }
  .table-title { font-size: 10px; padding: 3px 8px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .table-scroll { border-radius: 0 0 var(--radius-sm) var(--radius-sm); overflow: hidden; max-height: none; }
  #datatable { font-size: 9px; table-layout: fixed; width: 100%; }
  #datatable th:first-child, #datatable td:first-child { width: 16%; }
  #datatable th, #datatable td { padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #datatable thead th { position: static !important; }
  #datatable tbody td:first-child { position: static !important; }
}
