/*
 * Color values below are the actual tokens from "Magellan Design System -
 * Engineering Reference" (2026-09-21), mapped onto this file's existing token
 * names rather than adopting the source doc's own naming or its Clay
 * UI/Bootstrap/Liferay component layer - none of that infrastructure exists in
 * this app, and this pass is colors only. --danger-border has no direct
 * equivalent in the source (which defines only --danger and --danger-l2); it is
 * a midpoint between those two, called out here rather than left looking like a
 * fourth documented value.
 */
:root {
  color-scheme: light;

  --bg: #f7f8f9;           /* --light-l1 */
  --surface: #ffffff;
  --border: #e7e7ed;       /* --secondary-l3 */
  --border-strong: #cdced9; /* --secondary-l2 */
  --text: #272833;         /* --dark */
  --text-muted: #6b6c7e;   /* --secondary */
  --text-faint: #a7a9bc;   /* --secondary-l1 */

  --accent: #1071be;       /* --primary */
  --accent-hover: #05599c; /* --primary-d1 */
  --accent-soft: #f0f8ff;  /* --primary-l3 */

  --danger: #da1414;       /* --danger */
  --danger-bg: #feefef;    /* --danger-l2 */
  --danger-border: #ec8282; /* derived: midpoint of --danger and --danger-l2 */

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

/* The browser's own [hidden] default is display:none at the same specificity as a
   bare class selector, so whichever rule comes later in the stylesheet wins - .nav
   and .error-banner below both set their own `display`, which silently overrode
   `hidden` and is why a cleared, hidden error banner was still rendering as an empty
   box. [hidden] here outranks both by specificity, regardless of source order. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- loading */

/* Indeterminate, not a real progress percentage - nothing in this app tracks how
   much of a fetch is done, only whether one is in flight (see app.js's
   requireAuth). Fixed above the sticky topbar (higher z-index) so it stays
   visible regardless of scroll position, the same way the topbar itself does. */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  overflow: hidden;
  z-index: 20;
}

.loading-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: var(--accent);
  animation: loading-slide 1s ease-in-out infinite;
}

@keyframes loading-slide {
  0%   { left: -30%; }
  100% { left: 100%; }
}

/* ---------------------------------------------------------------- header */

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  height: 3.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.app-name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: 1.75rem;
  height: 100%;
}

.nav a {
  display: flex;
  align-items: center;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav a:hover { color: var(--text); }

.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.who {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  font-family: inherit;
  transition: color 0.15s;
}

.link-button:hover { color: var(--text); }

/* ----------------------------------------------------------- error banner */

.error-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  /* Matches main's own box below (max-width: 960px; padding: 2rem 1.5rem 4rem) so
     the banner lines up with the content edge at every viewport width, not just
     one - main's 1.5rem side padding never shows up as a narrower box (it has no
     background of its own to reveal the edge), but the banner's fill does, so it
     needs the equivalent width and gutter built in rather than copied from a
     single screenshot's width. */
  max-width: calc(960px - 3rem);
  width: calc(100% - 3rem);
  margin: 1rem auto 0;
  padding: 0.7rem 1rem;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.error-banner .link-button {
  color: var(--danger);
  opacity: 0.7;
  font-size: 1.1rem;
  line-height: 1;
}

.error-banner .link-button:hover { opacity: 1; }

/* ------------------------------------------------------------------ main */

main {
  display: block;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
}

/* ----------------------------------------------------------------- table */

/* The scrollable ancestor, not <table> itself, owns the border/radius/shadow now -
   a few hundred rows (Accounts, PO Boxes) otherwise turn "scroll" into "scroll the
   whole page past a table that never ends," losing the filters/actions above it and
   the column headers along with them. */
.table-scroll {
  max-height: calc(100vh - 14rem);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
}

th, td {
  text-align: left;
  padding: 0.7rem 1rem;
  white-space: nowrap;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: #fbfbfc;
  border-bottom: 1px solid var(--border);
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }

tbody tr:not(:last-child) td { border-bottom: 1px solid var(--border); }

tr.clickable { cursor: pointer; transition: background 0.1s; }
tr.clickable:hover { background: var(--accent-soft); }

/* ------------------------------------------------------------------ form */

form.record-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

form.record-form > p {
  margin: -0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

form.record-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

form.record-form label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  color: var(--text);
  font-weight: 400;
}

.required-mark {
  color: var(--danger);
}

/* A label's static, non-editable value - Okta-owned fields shown for reference
   only (see users.js). Not styled like an input: there is nothing to focus or
   edit, and looking like one would suggest otherwise. Overrides the muted
   caption color/weight the label itself carries, so the value still reads like
   real content rather than more caption text. */
.field-value {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
}

input, select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0 0.5rem 0 0;
  accent-color: var(--accent);
}

input:disabled, select:disabled {
  background: var(--bg);
  color: var(--text-faint);
}

a { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
a:hover { text-decoration: underline; }

/* --------------------------------------------------------------- buttons */

.actions { display: flex; gap: 0.6rem; margin-top: 0.25rem; flex-wrap: wrap; }

button {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

button.primary {
  background: var(--accent);
  color: white;
}
button.primary:hover { background: var(--accent-hover); }

button.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
button.secondary:hover { background: var(--bg); }

button.danger {
  background: var(--surface);
  border-color: var(--danger-border);
  color: var(--danger);
}
button.danger:hover { background: var(--danger-bg); }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- filters */

.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: end;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.filters input { min-width: 9rem; }

/* ------------------------------------------------------------- new/lists */

main > .actions { margin-bottom: 1.25rem; }

.empty-state {
  color: var(--text-muted);
  padding: 2.5rem 0;
  text-align: center;
  font-size: 0.9rem;
}

/* --------------------------------------------------------------- login */

body.login-mode main {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Not vertically centered in the viewport - on a tall monitor that leaves a lot of
     empty space above a small card. A fixed lead-in reads as an intentional login
     page at any window size; revisit once this is real Okta branding, not a form. */
  padding: 3.5rem 1.5rem;
}

body.login-mode .login-divider {
  width: 22rem;
  max-width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.field-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
}

body.login-mode form.record-form { width: 22rem; }
body.login-mode h1 { text-align: center; width: 100%; }
