/* SITU stylesheet. Consumes brand CSS custom properties (injected per-request in
   layout.html) ONLY — no hardcoded brand colors or fonts. See design.md. */

:root {
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 4px; --radius: 8px; --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow: 0 2px 8px rgba(0, 0, 0, .08);
  --maxw: 1100px;
  color-scheme: light dark; /* let the UA theme native controls + scrollbars */
}

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

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: var(--weight-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  line-height: 1.2;
  margin: 0 0 var(--space-4);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Layout ------------------------------------------------------------------ */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-head h1 { margin: 0; }

/* Nav --------------------------------------------------------------------- */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.nav-brand { display: inline-flex; align-items: center; }
.nav-brand img { height: 30px; width: auto; display: block; }
.nav-links { display: flex; gap: var(--space-4); flex: 1; }
.nav-links a { color: var(--text); font-weight: 500; }
.nav-links a:hover { color: var(--brand-primary); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: var(--space-3); }
.nav-username { color: var(--text-muted); font-size: .9rem; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { filter: brightness(.92); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--brand-secondary); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 0 var(--space-2); }
.btn-ghost:hover { color: var(--text); text-decoration: none; }
.btn-sm { min-height: 28px; padding: 0 var(--space-2); font-size: .85rem; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { color: var(--danger); filter: brightness(.85); }

/* Table row actions (edit / deactivate / delete) -------------------------- */
.row-actions { display: flex; gap: var(--space-1); align-items: center; }
.row-actions form { margin: 0; }
.row-inactive td { opacity: .55; }

/* Cards ------------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  color: var(--text);
  transition: box-shadow 150ms ease;
}
.card:hover { box-shadow: var(--shadow); text-decoration: none; }
.card-num { font-family: var(--font-display); font-weight: var(--weight-display); font-size: 2rem; color: var(--brand-primary); }
.card-label { color: var(--text-muted); margin-top: var(--space-1); }

/* Tables ------------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; background: var(--bg); }
.table th, .table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.table thead th { background: var(--surface); color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.table tbody tr:hover { background: var(--surface); }

/* Status badges ----------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-ok     { background: color-mix(in srgb, var(--ok) 14%, transparent);     color: var(--ok); }
.badge-info   { background: color-mix(in srgb, var(--info) 14%, transparent);   color: var(--info); }
.badge-warn   { background: color-mix(in srgb, var(--warn) 14%, transparent);   color: var(--warn); }
.badge-muted  { background: color-mix(in srgb, var(--muted) 22%, transparent);  color: var(--text-muted); }
.badge-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* Forms ------------------------------------------------------------------- */
.form { max-width: 560px; }
.field { margin-bottom: var(--space-4); }
.field label { display: block; margin-bottom: var(--space-1); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 20%, transparent);
}
.form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }

/* Flash ------------------------------------------------------------------- */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.flash-info   { background: color-mix(in srgb, var(--info) 10%, transparent);   border-color: var(--info);   color: var(--info); }
.flash-ok     { background: color-mix(in srgb, var(--ok) 10%, transparent);     border-color: var(--ok);     color: var(--ok); }
.flash-warn   { background: color-mix(in srgb, var(--warn) 10%, transparent);   border-color: var(--warn);   color: var(--warn); }
.flash-danger { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); color: var(--danger); }

/* Auth / error pages ------------------------------------------------------ */
.center-card {
  max-width: 380px;
  margin: var(--space-7) auto;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.center-card img { height: 40px; margin-bottom: var(--space-5); }
.error-page { text-align: center; padding: var(--space-7) 0; }
.error-page h1 { font-size: 3rem; color: var(--brand-primary); }

/* Filter chips ------------------------------------------------------------ */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.chip {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: .9rem;
}
.chip:hover { border-color: var(--brand-secondary); text-decoration: none; }
.chip-on { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.chip-on:hover { color: #fff; }

/* Detail spec list -------------------------------------------------------- */
.head-actions { display: flex; gap: var(--space-3); }
.spec {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0 0 var(--space-6);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.spec dt { color: var(--text-muted); font-weight: 600; }
.spec dd { margin: 0; }

/* Action cards (checkout / checkin / status) ------------------------------ */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.action-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.action-card h2 { font-size: 1.05rem; margin-bottom: var(--space-4); }
.action-card .field { margin-bottom: var(--space-3); }

.history { margin-top: var(--space-6); }

/* Search bar (asset list) ------------------------------------------------- */
.searchbar { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.searchbar input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.searchbar input[type="search"]:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 20%, transparent);
}

/* Sortable table headers -------------------------------------------------- */
.table-sortable thead th a { color: var(--text-muted); font-weight: 600; }
.table-sortable thead th a:hover { color: var(--brand-primary); text-decoration: none; }

/* Nav admin group label --------------------------------------------------- */
.nav-group-label {
  align-self: center;
  padding-left: var(--space-4);
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Inline field hint ------------------------------------------------------- */
.field-hint { margin: var(--space-1) 0 0; font-size: .85rem; }

/* Non-link stat card (dashboard, when not clickable) ---------------------- */
.card-static { cursor: default; box-shadow: var(--shadow-sm); }

/* Responsive: collapse tables to cards under md --------------------------- */
@media (max-width: 768px) {
  .nav { flex-wrap: wrap; gap: var(--space-3); }
  .nav-links { order: 3; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Dark mode ---------------------------------------------------------------
   Follows the OS/browser setting (no toggle, like prq). Overrides the
   brand-injected tokens (set inline in layout.html, before this file) with a
   slate palette. The brand blue (#162da7) and status hues are too dark on
   slate, so they're lifted for contrast. Brand logos are <img> SVGs whose fills
   can't be recolored from CSS, so they're rendered light via filter. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;          /* slate-900 */
    --surface: #1e293b;     /* slate-800 */
    --text: #f1f5f9;        /* slate-100 */
    --text-muted: #94a3b8;  /* slate-400 */
    --border: #334155;      /* slate-700 */
    --brand-primary: #6478f0;   /* lifted from #162da7 for contrast on slate */
    --brand-secondary: #c0c0c4;
    --info: #6478f0;
    --ok: #3fb950;
    --warn: #d29922;
    --danger: #f0564d;
    --muted: #64748b;
  }
  /* Navy+gray logos vanish on slate — render them light. */
  .nav-brand img,
  .center-card img { filter: brightness(0) invert(1); opacity: .9; }
  /* Black drop shadows are invisible on dark; rely on borders instead. */
  .card, .center-card { box-shadow: none; }
}
