/*
 * Shared styles for the Order Management family. Imported once by
 * routes/ordering/manage/+layout.svelte (so the rules are global) but every
 * selector is scoped under `.manage-shell` — the layout wrapper that contains
 * all child route markup — so nothing leaks into the rest of the app.
 *
 * Everything resolves from the design tokens in $lib/styles/theme.css so the
 * console re-themes (light/dark) automatically and stays visually consistent
 * with the rest of the app. No hard-coded colours.
 */

.manage-shell h2 { margin: 0 0 0.75rem; font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.manage-shell h3 { margin: 0 0 0.45rem; font-size: 0.86rem; font-weight: 700; color: var(--color-text-secondary); }
.manage-shell .mt { margin-top: 1.15rem; }
.manage-shell .muted { color: var(--color-text-muted); font-size: 0.84rem; margin: 0 0 0.65rem; }
.manage-shell .muted a { color: var(--color-brand); font-weight: 600; }
.manage-shell .muted a:hover { text-decoration: underline; }

.manage-shell .surface-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-bg-surface);
  padding: var(--space-card);
}

.manage-shell .split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

/* ── Tables: compact console rows, divider-separated ────────── */
.manage-shell table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.manage-shell th,
.manage-shell td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--color-divider); }
.manage-shell tr:last-child td { border-bottom: none; }
.manage-shell th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom-color: var(--color-border);
}
.manage-shell tbody tr { transition: background-color 140ms cubic-bezier(0.22, 1, 0.36, 1); }
.manage-shell tbody tr:hover { background: var(--color-surface-hover); }
.manage-shell tbody tr.selected { background: var(--color-surface-selected); }
.manage-shell table.clickable tbody tr { cursor: pointer; }

/* ── Status pills: neutral by default, tinted by tone ──────── */
.manage-shell .pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
  color: var(--color-text-secondary);
  background: color-mix(in srgb, var(--panel-soft) 70%, var(--color-bg-surface));
}
.manage-shell .pill.pos { color: var(--color-success-text); background: var(--color-success-tint); }
.manage-shell .pill.warn { color: var(--color-warning-text); background: var(--color-warning-tint); }
.manage-shell .pill.info { color: var(--color-info); background: var(--color-info-tint); }
.manage-shell .pill.danger { color: var(--color-error); background: color-mix(in srgb, var(--color-error) 14%, var(--color-bg-surface)); }

.manage-shell .tag {
  margin-left: 0.4rem;
  font-size: 0.64rem;
  font-weight: 600;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-warning-tint);
  color: var(--color-warning-text);
}
.manage-shell .empty { color: var(--color-text-muted); font-size: 0.85rem; margin: 0.2rem 0; }

/* ── Forms ──────────────────────────────────────────────────── */
.manage-shell .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 0.65rem; align-items: end; }
.manage-shell .form-grid .full { grid-column: 1 / -1; }
.manage-shell .form-grid label,
.manage-shell .form-row label { display: grid; gap: 0.28rem; font-size: 0.76rem; font-weight: 600; color: var(--color-text-secondary); }
.manage-shell .form-row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; margin-bottom: 0.6rem; }

.manage-shell .form-row input,
.manage-shell .form-row select,
.manage-shell .form-grid input,
.manage-shell .form-grid select,
.manage-shell .actions select,
.manage-shell .inline,
.manage-shell .ovr {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-input-bg);
  color: var(--color-text-primary);
  font: inherit;
  transition: border-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 140ms cubic-bezier(0.22, 1, 0.36, 1), background-color 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.manage-shell input:focus,
.manage-shell select:focus {
  outline: none;
  border-color: var(--color-brand);
  background: var(--color-bg-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 20%, transparent);
}
.manage-shell input:disabled,
.manage-shell select:disabled { opacity: 0.55; cursor: not-allowed; }

.manage-shell .check { display: flex; flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 600; color: var(--color-text-secondary); }
.manage-shell .check input { accent-color: var(--color-brand); width: 1rem; height: 1rem; }
.manage-shell .inline-label { flex-direction: row; align-items: center; gap: 0.5rem; }
.manage-shell .inline { width: 6.5rem; padding: 0.4rem 0.5rem; }
.manage-shell .ovr { width: 5.5rem; padding: 0.4rem 0.5rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.manage-shell .primary,
.manage-shell .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.3rem;
  border-radius: var(--radius-control);
  padding: 0.5rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 150ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.manage-shell .primary { background: var(--color-brand); border-color: var(--color-brand); color: var(--color-on-brand); }
.manage-shell .primary:hover:not(:disabled) { background: var(--color-brand-hover); border-color: var(--color-brand-hover); }
.manage-shell .secondary { background: var(--color-bg-surface); border-color: var(--color-border); color: var(--color-text-primary); }
.manage-shell .secondary:hover:not(:disabled) { background: var(--color-surface-hover); }
.manage-shell .primary:disabled,
.manage-shell .secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.manage-shell .link {
  background: none;
  border: none;
  color: var(--color-brand);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
}
.manage-shell .link:hover { text-decoration: underline; }

/* ── Order / customer detail ────────────────────────────────── */
.manage-shell .lines td { font-size: 0.82rem; }
.manage-shell .detail-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0.05rem;
  border-top: 1px solid var(--color-border);
  margin: 0.5rem 0 0.85rem;
  font-size: 0.86rem;
  color: var(--color-text-secondary);
}
.manage-shell .detail-total strong { font-size: 1.05rem; color: var(--color-text-primary); }
.manage-shell .actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.manage-shell .history { margin-top: 0.95rem; font-size: 0.8rem; color: var(--color-text-secondary); }
.manage-shell .history summary { cursor: pointer; font-weight: 600; color: var(--color-text-secondary); }
.manage-shell .history summary:hover { color: var(--color-text-primary); }
.manage-shell .history ul { margin: 0.5rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.3rem; }

.manage-shell .mini { list-style: none; margin: 0.3rem 0 0.7rem; padding: 0; display: grid; gap: 0.4rem; font-size: 0.82rem; }
.manage-shell .mini li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--panel-soft);
}
.manage-shell .visibility li { justify-content: flex-start; }

/* ── Card header: title on the left, primary action on the right ── */
.manage-shell .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.manage-shell .card-head h2 { margin: 0; }

/* ── Modal ──────────────────────────────────────────────────── */
.manage-shell .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: 10vh 1rem 1rem;
  background: color-mix(in srgb, var(--color-text-primary) 32%, transparent);
  backdrop-filter: blur(8px);
}
.manage-shell .modal {
  width: min(30rem, 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-bg-surface);
  padding: var(--space-card);
}
.manage-shell .modal.wide { width: min(40rem, 100%); }
.manage-shell .modal h2 { margin: 0 0 1rem; }
.manage-shell .modal .actions { justify-content: flex-end; margin-top: 1.15rem; }

/* ── Console primitives: shared master/detail vocabulary ─────
 * Reusable across the management console (products, orders, …) so each page
 * reads the same. Everything resolves from design tokens. */

/* Two-pane master/detail: a list on the left, a sticky detail on the right. */
.manage-shell .console-split {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.7fr);
  gap: 1rem;
  align-items: start;
}
.manage-shell .console-split > .detail {
  position: sticky;
  top: 1rem;
}

/* Count chip beside a heading. */
.manage-shell .count {
  margin-left: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Full-width search field above a list. */
.manage-shell .list-search {
  width: 100%;
  margin-bottom: 0.7rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-input-bg);
  color: var(--color-text-primary);
  font: inherit;
  transition: border-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 140ms cubic-bezier(0.22, 1, 0.36, 1), background-color 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.manage-shell .list-search:focus {
  outline: none;
  border-color: var(--color-brand);
  background: var(--color-bg-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 20%, transparent);
}

/* Inline reveal panel for create forms (replaces create modals). */
.manage-shell .create-panel {
  margin-bottom: 0.85rem;
  padding: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--panel-soft);
}
.manage-shell .create-panel .actions { justify-content: flex-end; margin-top: 0.85rem; }

/* Two-line identity cell: bold name over a muted sub-line. */
.manage-shell .id-cell { display: grid; gap: 0.12rem; min-width: 0; }
.manage-shell .id-name { font-size: 0.88rem; font-weight: 600; color: var(--color-text-primary); }
.manage-shell .id-sub { font-size: 0.74rem; color: var(--color-text-muted); }

/* Detail header: title block left, status + actions right. */
.manage-shell .detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding-bottom: 0.95rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--color-divider);
}
.manage-shell .detail-title h2 { margin: 0; font-size: 1.2rem; }
.manage-shell .eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.manage-shell .detail-head-actions { display: inline-flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* Square icon button (close, etc.). */
.manage-shell .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-bg-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background-color 150ms cubic-bezier(0.22, 1, 0.36, 1),
    color 150ms cubic-bezier(0.22, 1, 0.36, 1), border-color 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.manage-shell .icon-btn:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.manage-shell .icon-btn svg { display: block; }

/* Section sub-header inside a detail panel. */
.manage-shell .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}
.manage-shell .section-head h3 { margin: 0; }

/* Inline meta chips (PO, fulfilment, dates). */
.manage-shell .meta { display: flex; flex-wrap: wrap; gap: 0.45rem 1.1rem; margin: 0.2rem 0 1rem; }
.manage-shell .meta-item { display: grid; gap: 0.1rem; }
.manage-shell .meta-item span {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.manage-shell .meta-item strong { font-size: 0.84rem; font-weight: 600; color: var(--color-text-primary); }

/* Centered empty state for an unselected detail pane. */
.manage-shell .empty-detail {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
}
.manage-shell .empty-detail h2 { margin: 0; }
.manage-shell .empty-detail .muted { max-width: 28rem; margin: 0; }
.manage-shell .empty-icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.95rem;
  background: var(--color-brand-tint);
  color: var(--color-brand);
}

/* Status pill that reads as Active / Disabled from a boolean. */
.manage-shell .pill.muted-pill {
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--panel-soft) 70%, var(--color-bg-surface));
}

/* ── Workspace shell: a pinned header + tabs over a scrolling body ───
 * Gives a detail pane the feel of an anchored management surface. The head
 * (title, status, tabs, primary actions) stays put while the body scrolls,
 * capped to the viewport so the list beside it is always reachable. */
.manage-shell .workspace {
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}
.manage-shell .workspace-head {
  flex-shrink: 0;
  padding: var(--space-card) var(--space-card) 0;
  border-bottom: 1px solid var(--color-divider);
}
.manage-shell .workspace-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--space-card);
}

.manage-shell .workspace-tabs {
  display: flex;
  gap: 0.1rem;
  margin-top: 0.9rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.manage-shell .workspace-tabs::-webkit-scrollbar { display: none; }
.manage-shell .workspace-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.manage-shell .workspace-tab:hover { color: var(--color-text-primary); }
.manage-shell .workspace-tab[aria-selected='true'] {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}
.manage-shell .workspace-tab svg { display: block; }
.manage-shell .workspace-tab .tab-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.manage-shell .workspace-tab[aria-selected='true'] .tab-count { color: var(--color-brand); }

/* Vertical rhythm for stacked sections inside a workspace body. */
.manage-shell .ws-section + .ws-section { margin-top: 1.4rem; }

@media (max-width: 1000px) {
  .manage-shell .split,
  .manage-shell .console-split,
  .manage-shell .form-grid { grid-template-columns: 1fr; }
  .manage-shell .console-split > .detail { position: static; }
  .manage-shell .workspace { max-height: none; }
}
