/* ================================================================
   fv-dashboard — dark-theme neuroimaging visualization portal
   ================================================================ */

:root {
  --bg: #0f1117;
  --bg-raised: #161924;
  --bg-card: #1a1d2e;
  --bg-card-hover: #1f2338;
  --border: #2a2d3e;
  --text: #e0e0e0;
  --text-muted: #8a8fa0;
  --accent: #6c8aff;
  --accent-hover: #8da4ff;
  --accent-dim: rgba(108, 138, 255, 0.12);
  --green: #4ade80;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --max-width: 1200px;
  --nav-height: 56px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Navigation ---- */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  overflow: visible;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
  margin-right: 2rem;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links > a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.nav-links > a:hover,
.nav-links > a.active {
  color: var(--text);
  background: var(--accent-dim);
}

/* ---- Nav dropdowns ---- */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-dropdown-toggle::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0.35rem;
  vertical-align: 0.1em;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 0.35rem 0;
  z-index: 110;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.45rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.1s, background 0.1s;
}

.nav-dropdown-menu a:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-dropdown-menu a.active {
  color: var(--accent);
}

/* ---- Layout ---- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.page-header .subtitle {
  font-size: 1rem;
  color: var(--text-muted);
}

.page-header .description {
  margin-top: 1rem;
  color: var(--text-muted);
  max-width: 72ch;
  line-height: 1.7;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

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

.breadcrumb span {
  margin: 0 0.4rem;
}

/* ---- Section headings ---- */

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ---- Card grid ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

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

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

.card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.6;
}

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

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--accent-dim);
  color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(108, 138, 255, 0.2);
  color: var(--accent-hover);
}

/* ---- Nav cards (landing page) ---- */

.nav-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

.nav-card .card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.nav-card .card p {
  flex: 1;
}

.card-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.card-tag.qc {
  background: rgba(74, 222, 128, 0.12);
  color: var(--green);
}

.card-tag.sanity {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

/* ---- Tables (MRIQC) ---- */

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

.report-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.report-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.report-table tr:hover td {
  background: var(--bg-card);
}

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

.report-table a:hover {
  text-decoration: underline;
}

.session-header td {
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 1.25rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: none;
  border-bottom: 2px solid var(--border);
}

/* ---- Image gallery (FreeSurfer QC) ---- */

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.image-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

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

.image-card img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
}

.image-card .image-label {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---- Lightbox ---- */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 201;
  background: none;
  border: none;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ---- Responsive ---- */

@media (max-width: 640px) {
  .container {
    padding: 1.25rem;
  }

  .nav {
    padding: 0 1rem;
  }

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

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

  .page-header h1 {
    font-size: 1.35rem;
  }
}
