/* ============================================================================
   Settings (E): the area's own section list beside each settings page, the
   save bar that appears with unsaved changes, and the hub's "needs you" line.
   Markup: layouts/application.html.erb (settings-shell), bootSaveBars.
   ============================================================================ */
.settings-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.settings-nav-title { margin: 0 0 8px 10px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.settings-nav-group {
  margin: 14px 0 4px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
}
.settings-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
}
.settings-nav-link:hover { background: var(--hover); color: var(--text); }
.settings-nav-link.is-active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.settings-nav-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
.settings-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-nav-link.is-locked .settings-nav-label { opacity: 0.72; }
.settings-nav-hint { font-size: 12px; color: var(--faint); white-space: nowrap; }
.settings-nav-hint.is-warn { color: var(--amber); }
.settings-nav-hint.is-ok { color: var(--accent); }
.settings-nav-hint.is-locked { color: var(--amber); }
.settings-nav-out { flex: none; color: var(--faint); }

/* The pages' own "< Settings" pill is the section list's job beside it. */
.settings-main .back-pill[href="/settings"] { display: none; }
.settings-main { min-width: 0; }

/* The save bar. Ink, full width, pinned to the bottom of the window. */
.save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 66;
  background: var(--text);
  color: #fff;
}
.save-bar[hidden] { display: none; }
.save-bar-in {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(var(--content-max) + 2 * var(--page-gutter));
  margin: 0 auto;
  padding: 12px var(--page-gutter);
}
.save-bar-text { flex: 1; min-width: 0; font-size: 14px; }
.save-bar-what { color: rgba(255, 255, 255, 0.64); }
.save-bar-discard,
.save-bar-save {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font: 500 14px var(--font);
  cursor: pointer;
}
.save-bar-discard { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.28); }
.save-bar-discard:hover { background: rgba(255, 255, 255, 0.08); }
.save-bar-save { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.save-bar-save:hover { background: #1a8f74; }
.save-bar-discard:focus-visible,
.save-bar-save:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
html.has-save-bar .page-content { padding-bottom: 96px; }
/* Scrolling a field into view (focus, a label click, find-in-page) stops clear
   of both fixed bars rather than under them. */
html { scroll-padding-top: calc(var(--topbar-height) + 12px); }
html.has-save-bar { scroll-padding-bottom: 88px; }

@media (max-width: 1023px) {
  /* The section list becomes a row of chips over the page. */
  .settings-shell { grid-template-columns: 1fr; gap: 16px; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .settings-nav-title, .settings-nav-group, .settings-nav-out { display: none; }
  .settings-nav-link { flex: none; border-color: var(--line); background: var(--panel); border-radius: 999px; }
  .settings-nav-hint { display: none; }
  .settings-main .back-pill[href="/settings"] { display: inline-flex; }
}

@media (max-width: 639px) {
  .save-bar-what { display: none; }
}

/* E: figures in tables read in the mono face - totals, counts, money - so a
   column of numbers lines up digit for digit. The right-aligned cell is the
   app's number cell everywhere (orders, vendors, payouts, the sales breakdown). */
.data-table td.align-right { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* An error about one field, under that field (bootFieldErrors; Built for
   Shopify 4.2.4): red text, and the field outlined in the same red. #b42318 on
   white is 6.5:1, inside WCAG AA. */
.field-error {
  margin: 6px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 560;
  line-height: 1.4;
}
.field-error::before { content: "\26A0\FE0E\00A0"; }
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-weak);
}

/* Inside the Shopify admin, buttons look like the admin's (Built for Shopify
   4.1.1: primary buttons in Polaris' colour, not the brand green). The
   standalone app keeps its own. Values follow Polaris' button tokens. Written
   specific enough (html.is-embedded ... :not([disabled])) to win over the pages
   that set their own green hover (.orders-page .button:hover, ...). */
html.is-embedded .button-primary {
  color: #ffffff;
  background: #303030;
  border-color: #303030;
  border-radius: 8px;
  box-shadow: inset 0 -1px 0 0 #000000, inset 0 1px 0 0 rgba(255, 255, 255, 0.25);
}
html.is-embedded .button-primary:hover:not([disabled]) {
  background: #1a1a1a;
  border-color: #1a1a1a;
}
html.is-embedded .button-primary:active:not([disabled]) {
  background: #000000;
  box-shadow: inset 0 2px 1px 0 rgba(0, 0, 0, 0.6);
}

html.is-embedded .button,
html.is-embedded .button:disabled,
html.is-embedded .button[disabled],
html.is-embedded .button:disabled:hover,
html.is-embedded .button[disabled]:hover {
  color: #303030;
  background: #ffffff;
  border-color: #e3e3e3;
  border-radius: 8px;
  box-shadow: inset 0 -1px 0 0 #b5b5b5;
}
html.is-embedded .button:hover:not([disabled]) {
  color: #303030;
  background: #f7f7f7;
  border-color: #e3e3e3;
}
html.is-embedded .button:active:not([disabled]) {
  background: #f1f1f1;
  box-shadow: inset 0 1px 0 0 #d4d4d4;
}

/* Inside the Shopify admin the admin's sidebar takes ~240px, so a laptop-sized
   window gives the app a frame under 1024px, where the template editors stack
   and hide the preview behind an Edit/Preview toggle. Built for Shopify 4.2.6:
   on desktop, the controls and the preview are visible together. So in the
   admin they stay side by side down to tablet width (768px). */
@media (min-width: 768px) and (max-width: 1023px) {
  html.is-embedded .split-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }
  html.is-embedded .split-layout > .section-card {
    max-height: calc(100vh - 118px);
  }
  html.is-embedded .template-preview,
  html.is-embedded .pack-editor-preview {
    position: sticky;
  }
  /* The themed sheet sets top: auto (it is a document, not a pane); here it is
     the pane again, so it keeps the base rule's offset. */
  html.is-embedded .template-preview[data-theme] { top: 94px; }
  html.is-embedded .editor-viewtab {
    display: none;
  }
  html.is-embedded .split-layout[data-editor-view] .template-preview { display: block; }
  html.is-embedded .split-layout[data-editor-view] .pack-editor-preview { display: grid; }
  html.is-embedded .split-layout[data-editor-view] .invoice-editor-shell { display: grid; }
}

/* Send history (partials/send_history): what happened to each document sent for
   an order, newest first. The mark carries the outcome; the words say it too. */
.send-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.send-history-row { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; align-items: start; }
.send-history-mark { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--faint); }
.send-history-row.is-delivered .send-history-mark,
.send-history-row.is-sent .send-history-mark { background: var(--accent); }
.send-history-row.is-failed .send-history-mark { background: var(--red); }
.send-history-row.is-pending .send-history-mark { background: var(--amber); }
.send-history-what { margin: 0; font-weight: 600; }
.send-history-row.is-failed .send-history-what { color: var(--red); }
.send-history-when { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.send-history-why { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* The drawer's order total and its last few sends. */
.odrawer-total { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 0; }
.odrawer-total span { font-size: 12px; color: var(--muted); }
.odrawer-total strong { font-size: 20px; font-weight: 650; }

