/* jcdash-logs — custom design system layered on Pico.css
   Goal: a polished "motorsport telemetry" look — dark branded header, tinted
   canvas, elevated white cards, a confident red accent, and clean type. */

:root {
  /* Pin the base size — Pico otherwise scales rem up on large screens,
     making everything oversized on wide monitors. */
  font-size: 16px;
  /* palette */
  --bg-1: #eef1f6;
  --bg-2: #e5e9f2;
  --surface: #ffffff;
  --ink: #0b1220;
  --muted: #64748b;
  --line: #e4e8f0;
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-soft: #fff1f3;
  --header: #0b1220;
  --header-ink: #e7ebf3;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 12px 28px -14px rgba(16, 24, 40, 0.28);
  --radius: 14px;

  /* Pico overrides (theme-independent tokens) */
  --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pico-border-radius: 10px;
  --pico-form-element-spacing-vertical: 0.7rem;
  --pico-form-element-spacing-horizontal: 0.9rem;
  --pico-spacing: 1.1rem;
}

/* Accent (primary) colours — must match Pico's specificity, which scopes these
   under :root:not([data-theme=dark]) / [data-theme]; a plain :root loses. */
:root:not([data-theme="dark"]),
[data-theme="light"],
[data-theme="dark"] {
  --pico-primary: var(--accent);
  --pico-primary-background: var(--accent);
  --pico-primary-border: var(--accent);
  --pico-primary-hover: var(--accent-hover);
  --pico-primary-hover-background: var(--accent-hover);
  --pico-primary-hover-border: var(--accent-hover);
  --pico-primary-focus: rgba(225, 29, 72, 0.35);
  --pico-primary-inverse: #ffffff;
  --pico-primary-underline: rgba(225, 29, 72, 0.5);
}

/* base canvas */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 100% -20%, rgba(225, 29, 72, 0.06) 0%, rgba(225, 29, 72, 0) 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
}
main.container {
  max-width: none;
  width: 100%;
  padding-block: 0 3rem;
  padding-inline: clamp(1rem, 3vw, 2.5rem);
}
h1, h2, h3 { letter-spacing: -0.02em; }
h1 { font-weight: 750; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--accent-soft); color: var(--accent-hover); }

/* ---------------- header ---------------- */
.site-header {
  background: var(--header);
  border-bottom: 1px solid #131c2e;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  margin-bottom: 2rem;
}
/* force a horizontal menu bar regardless of Pico's nav behaviour */
.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 3.5rem;
  max-width: none;
  padding-block: 0;
  padding-inline: clamp(1rem, 3vw, 2.5rem);
}
.site-header nav ul {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* every menu item is a centered flex item of equal height — no baseline drift */
.site-header nav li {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-header nav li > * { margin: 0; }
.site-header nav form { margin: 0; display: flex; align-items: center; }
.site-header nav button, .site-header nav [role="button"] { margin: 0; }
.site-header nav a { color: var(--header-ink); }
.site-header nav a:hover { color: #fff; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; color: #fff; }
.brand-mark {
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  padding: 0.15rem 0.5rem;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 8px -2px rgba(225, 29, 72, 0.6);
}
.site-header .brand span:last-child { color: #aeb8cc; font-weight: 600; font-size: 0.92rem; }
.site-header .user-chip { color: #8b97ad; font-size: 0.88rem; }
.site-header nav ul:first-child li:not(:first-child) a { color: #c4ccdb; font-weight: 500; }
.site-header .secondary.outline {
  --pico-color: #c4ccdb;
  border-color: #2b3852;
  color: #c4ccdb;
  padding: 0.35rem 0.8rem;
}
.site-header .secondary.outline:hover { color: #fff; border-color: #3b4a68; background: #17223a; }

/* ---------------- cards ---------------- */
.card,
figure {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 1.6rem 1.7rem; margin-bottom: 1.75rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.section-head h2 { margin: 0; }
.muted { color: var(--muted); }
.page-intro { margin-bottom: 1.5rem; }
.page-intro h1 { margin-bottom: 0.15rem; }

/* ---------------- buttons ---------------- */
button, [role="button"], input[type="submit"] { font-weight: 600; border-radius: 10px; }
a[role="button"] { text-decoration: none; }
/* action button rows: all items same height, centered, no stray margins */
.btn-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.btn-row form { margin: 0; display: inline-flex; }
.btn-row button,
.btn-row a[role="button"],
.btn-row input[type="submit"] { margin: 0; }

/* ---------------- forms ---------------- */
.app-form label, .stacked-form label {
  display: block; font-weight: 600; font-size: 0.9rem; color: #334155; margin-bottom: 0.35rem;
}
.app-form input, .app-form select, .stacked-form input {
  display: block; width: 100%;
}
.app-form .field { margin-bottom: 1.05rem; }
.app-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0 1.1rem; }
.app-form fieldset { border: 1px dashed var(--line); border-radius: 10px; padding: 1rem 1.1rem 0.2rem; margin: 0.4rem 0 1.1rem; }
.app-form legend { font-weight: 600; font-size: 0.85rem; color: var(--muted); padding: 0 0.4rem; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.4rem; }
.form-actions button, .form-actions [role="button"] { width: auto; margin: 0; }

/* horizontal conversion bar (dashboard top card) */
.convert-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.1rem;
  align-items: flex-end;
}
.convert-bar .field { margin: 0; flex: 1 1 12rem; min-width: 0; }
.convert-bar .field label { margin-bottom: 0.35rem; }
.convert-bar .field input,
.convert-bar .field select { margin: 0; }
.convert-bar .field-rate { flex: 0 0 7rem; }
.convert-bar .field-submit { flex: 0 0 auto; align-self: flex-end; }
.convert-bar .field-submit button { margin: 0; }
.convert-meta { margin-top: 1.1rem; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.convert-meta-label { color: var(--muted); font-weight: 600; font-size: 0.9rem; margin: 0 0 0.6rem; }
.convert-meta .row { margin-top: 0; }
.convert-meta .field { margin-bottom: 0; }

/* action bars on list pages — same visual family as the convert bar */
.toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.toolbar > [role="button"] { margin: 0; }         /* primary "+ New" on the left */
.toolbar .import { margin: 0 0 0 auto; display: flex; gap: 0.5rem; align-items: center; }
.toolbar .import input[type="file"] { margin: 0; max-width: 18rem; font-size: 0.9rem; }
.toolbar .import button { margin: 0; }

/* ---------------- filters + sortable headers ---------------- */
.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.filters select { margin: 0; min-width: 9rem; }
.filters-clear { align-self: center; font-size: 0.85rem; }
a.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
a.sort-link:hover { color: var(--accent); text-decoration: none; }

/* real checkbox sizing (Pico's appearance reset can collapse them) */
input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: auto;
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  margin: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

/* jobs table column balance (col 1 is the select checkbox) */
table.jobs th.col-check, table.jobs td.col-check { width: 2.4rem; text-align: center; }
table.jobs th:nth-child(2) { width: 26%; }               /* File */
table.jobs th:nth-child(3), table.jobs th:nth-child(4) { width: 16%; }  /* Vehicle, Venue */
table.jobs th:nth-child(5) { width: 10rem; }             /* Created */
table.jobs th:nth-child(6), table.jobs td:nth-child(6) { width: 6rem; white-space: nowrap; }  /* Status */

/* bulk action bar */
.bulk-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.bulk-bar .bulk-count { align-self: center; white-space: nowrap; }
.bulk-bar .bulk-fields { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.bulk-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
/* zero Pico's default control margins so everything sits on one baseline */
.bulk-bar select, .bulk-bar input, .bulk-bar button { margin: 0; }
.bulk-bar select, .bulk-bar input[type="number"] { height: 2.6rem; }
.bulk-bar select { min-width: 11rem; }
.bulk-bar input[type="number"] { width: 8rem; }
.bulk-bar .bulk-actions { display: flex; align-items: flex-end; gap: 0.5rem; margin-left: auto; }
.bulk-bar .bulk-actions button { white-space: nowrap; }

/* ---------------- tables ---------------- */
figure { overflow: hidden; margin: 0; }
figure table { margin: 0; }
table thead th {
  background: #f7f8fb; color: #475569; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.03em; border-bottom: 1px solid var(--line);
}
table tbody tr { transition: background 0.12s ease; }
table tbody tr:hover { background: #fafbfe; }
table td, table th { padding: 0.7rem 0.9rem; vertical-align: middle; }
.row-actions { display: inline-flex; gap: 0.4rem; }
.row-actions button,
.row-actions a[role="button"] {
  margin: 0;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-block; padding: 0.18rem 0.65rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; text-transform: capitalize;
  background: #eef2f7; color: #334155;
}
.badge-queued { background: #eef2f7; color: #475569; }
.badge-running { background: #e0edff; color: #1d4ed8; }
.badge-complete { background: #dcfce7; color: #15803d; }
.badge-failed { background: #ffe4e6; color: #be123c; }

/* ---------------- auth ---------------- */
.auth-shell { min-height: calc(100vh - 6rem); display: grid; place-items: center; padding: 1rem; }
.auth-card {
  width: 100%; max-width: 27rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 2.25rem 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.auth-card .brand { justify-content: flex-start; margin-bottom: 0.6rem; }
.auth-card .brand .brand-mark { font-size: 1.05rem; padding: 0.25rem 0.6rem; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 1.6rem; }
.auth-card button { width: 100%; margin-top: 0.6rem; }
.form-error {
  background: var(--accent-soft); color: var(--accent-hover); border: 1px solid #fecdd3;
  border-radius: 10px; padding: 0.65rem 0.85rem; font-size: 0.9rem; margin-bottom: 1.1rem;
}

/* dark theme softening */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-1: #0d1220; --bg-2: #0a0f1b; --surface: #121a2b; --ink: #e7ebf3;
    --muted: #93a0b8; --line: #22304a; --accent-soft: #2a1420;
  }
  :root:not([data-theme="light"]) table thead th { background: #16203350; color: #93a0b8; }
  :root:not([data-theme="light"]) table tbody tr:hover { background: #16203330; }
  :root:not([data-theme="light"]) .app-form label,
  :root:not([data-theme="light"]) .stacked-form label { color: #c4ccdb; }
}
