/*
 * The logged-in shell: top bar, tables, forms, dialogs, toasts.
 *
 * app.css holds the design tokens and the standalone health page. This file
 * is everything that only exists once somebody is signed in, so the health
 * page stays loadable even if this stylesheet is missing.
 */

a { color: var(--purple-mid); }
a:hover { color: var(--purple); }

/* ----------------------------------------------------------------- shell -- */

/*
 * A sidebar rather than a top bar: the menu grew past what a single row can
 * hold once positions, shifts and templates arrived, and it will grow again
 * with tasks, inventory and production. Grouping them vertically means a new
 * module is a new line, not a redesign.
 *
 * In right-to-left the sidebar sits on the right, which is also where the
 * Violet wordmark belongs.
 */

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.shell-main { min-width: 0; display: flex; flex-direction: column; }

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
}

.skip-link:focus {
  inset-inline-start: 12px;
  top: 12px;
  z-index: 50;
  background: var(--paper);
  padding: 8px 14px;
  border-radius: 6px;
  border: 2px solid var(--orange);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------- sidebar -- */

.sidebar {
  background: var(--paper);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: block;
  padding: 22px 20px 18px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.sidebar-logo { display: block; height: 34px; width: auto; }

.sidebar-brand-sub {
  display: block;
  margin-top: 8px;
  font-size: 10.5px;
  letter-spacing: .26em;
  font-weight: 700;
  color: var(--caramel);
}

.sidebar-nav { padding: 14px 12px; flex: 1; }

.nav-group { margin-bottom: 18px; }

.nav-group-title {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--muted);
  padding: 0 10px 6px;
}

.nav-link {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  border-inline-start: 3px solid transparent;
}

.nav-link:hover { background: var(--cream); color: var(--purple); }

.nav-link.is-active {
  background: var(--cream);
  color: var(--purple);
  border-inline-start-color: var(--orange);
}

.nav-group-soon { opacity: .55; }

.nav-link-soon {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: default;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 18px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.whoami { line-height: 1.5; display: flex; flex-direction: column; min-width: 0; }
.whoami-name { font-size: 13px; font-weight: 700; color: var(--purple); }
.whoami-roles {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------- mobile bar -- */

.mobilebar { display: none; }

.menu-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.menu-bars, .menu-bars::before, .menu-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--purple);
  border-radius: 2px;
}

.menu-bars { position: relative; }
.menu-bars::before, .menu-bars::after { content: ""; position: absolute; }
.menu-bars::before { top: -6px; }
.menu-bars::after { top: 6px; }

.mobilebar-logo { height: 26px; width: auto; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(46, 31, 22, .4);
  z-index: 20;
}

/* -------------------------------------------------------------------- page */

.page { max-width: 1100px; margin: 0 auto; padding: 26px 24px 60px; width: 100%; }
.pagefoot { max-width: 1100px; margin: 0 auto; padding: 0 24px 30px; font-size: 12px; color: var(--muted); width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h1 { font-size: 22px; font-weight: 800; color: var(--purple); }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; max-width: 70ch; }

.section { margin-top: 28px; }
.section h2 { font-size: 16px; font-weight: 800; color: var(--purple); margin-bottom: 10px; }

.module-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--caramel);
  letter-spacing: .04em;
  margin: 18px 0 8px;
}

.note {
  background: #FDF6F0;
  border-inline-start: 3px solid var(--orange);
  border-radius: 0 6px 6px 0;
  padding: 10px 13px;
  font-size: 13px;
  color: #4A3A31;
  margin-bottom: 12px;
  max-width: 80ch;
}

.banner { padding: 10px 20px; font-size: 13.5px; text-align: center; }
.banner-warn { background: var(--orange-pale); color: var(--amber); }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }

/* ------------------------------------------------------------------- cards */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  display: block;
}

.card:hover { border-color: var(--purple-pale); }
.card-quiet { background: var(--cream); }
.card-value { display: block; font-size: 26px; font-weight: 800; color: var(--purple); }
.card-label { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

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

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}

.table th {
  background: #F4EEE9;
  color: var(--purple);
  font-weight: 700;
  font-size: 12.5px;
  text-align: right;
  padding: 10px 12px;
}

.table td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.table-tight td, .table-tight th { padding: 7px 10px; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }

.nowrap { white-space: nowrap; }
.center { text-align: center; }
.block { display: block; }
.muted { color: var(--muted); font-size: 12px; }
.yes { color: var(--green); font-weight: 700; }
.no { color: var(--muted); }

.mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  direction: ltr;
  unicode-bidi: plaintext;
  font-size: 12px;
}

.diff { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.diff-old { color: var(--red); text-decoration: line-through; font-size: 12px; }
.diff-new { color: var(--green); font-size: 12px; }
.diff-arrow { color: var(--muted); }

.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pill-on { background: var(--green-pale); color: var(--green); }
.pill-off { background: #F0EAE4; color: var(--muted); }
.pill-warn { background: var(--orange-pale); color: var(--amber); }
.pill-sys { background: #E4E7F3; color: #3B4682; }

.plain-list { list-style: none; }
.plain-list li { padding: 6px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: none; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { color: var(--ink); }

/* ------------------------------------------------------------------- forms */

.form-narrow { max-width: 420px; }
.form-padded { padding: 20px 24px 4px; }

.field { margin-bottom: 16px; }
.field > label,
.field > legend { display: block; font-size: 13px; font-weight: 700; color: var(--purple); margin-bottom: 5px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
}

.field input:focus,
.field select:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; }
.field input:disabled,
.field select:disabled { background: var(--cream); color: var(--muted); }

.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.field.has-error input,
.field.has-error select { border-color: var(--red); }

.form-error {
  background: var(--red-pale);
  color: var(--red);
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.field-row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(160px, 260px); gap: 12px; align-items: start; }
.field-label label { font-size: 13.5px; font-weight: 700; color: var(--purple); }

.checks { display: flex; flex-direction: column; gap: 8px; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px; }

.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--purple); flex-shrink: 0; }
.check.is-muted { opacity: .6; }

.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { margin-bottom: 0; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

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

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--purple);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.6;
}

.btn:hover { border-color: var(--purple-pale); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-mid); border-color: var(--purple-mid); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-quiet { background: transparent; }
.btn-sm { font-size: 12.5px; padding: 5px 12px; }
.btn-block { width: 100%; }

.row-actions { text-align: left; white-space: nowrap; }
.row-actions-block { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; text-align: right; }

/* ----------------------------------------------------------------- dialogs */

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
  width: calc(100% - 32px);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  max-height: 85vh;
}

.dialog::backdrop { background: rgba(46, 31, 22, .45); }
.dialog h2 { font-size: 17px; font-weight: 800; color: var(--purple); margin-bottom: 14px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }

/* A one-time password is read aloud or copied; it has to be unambiguous. */
.credential {
  font-size: 18px;
  letter-spacing: .06em;
  background: var(--cream);
  border: 1px dashed var(--caramel);
  border-radius: 7px;
  padding: 12px;
  text-align: center;
  user-select: all;
  direction: ltr;
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-start: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
}

.toast {
  background: var(--purple);
  color: #fff;
  border-radius: 8px;
  padding: 11px 38px 11px 14px;
  font-size: 13.5px;
  position: relative;
  box-shadow: 0 6px 20px rgba(46, 31, 22, .18);
}

.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

.toast-close {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 8px;
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: .8;
}

.panel-narrow { max-width: 420px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  /* Off-canvas rather than stacked: a menu this tall would otherwise push the
     page itself below the fold on every load. */
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: 260px;
    z-index: 30;
    transform: translateX(100%);
    transition: transform .2s ease;
    box-shadow: -8px 0 24px rgba(46, 31, 22, .12);
  }

  .shell.menu-open .sidebar { transform: translateX(0); }

  .mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .field-row { grid-template-columns: 1fr; }
  .page { padding: 18px 14px 50px; }
}

@media print {
  .sidebar, .mobilebar, .toasts, .row-actions, .filters, .pager, .btn { display: none; }
  .shell { display: block; }
  body { background: #fff; }
  .table { border: none; }
}

/* ------------------------------------------------------------------ misc -- */

.check-lead { margin-top: 6px; font-weight: 700; }

.secret {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  direction: ltr;
  text-align: center;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
  font-size: 15px;
  user-select: all;
}
