/* apps/admin/admin.css — page layout of the admin only. Components keep their own styles (packages/ui).
   Layout mirrors Figma BACKEND → Create ("Create listing - desktop", 1024): padding 24, 12-column grid gap 16, main 8 + side 4 columns, full width,
   sections gap 32 separated by Divider, field rows = 8-column grid, gap 16 (decision 0012).
   Track lines, the action panel and dividers are DS components (ListingLine, ActionPanel, Divider): only page layout here.
   Listings: Figma BACKEND → Listings (2026-11-10). Sign-in has no Figma frame (design/open.md). */

* { box-sizing: border-box; }
/* every admin page sits on surface-page (backend: scotch-mist, the cream; decision 0100, replaces the per-page grounds of 0023 / 0032 / 0057).
   On html only, so nothing stacks; fields keep surface-accent (black-a4) over it. */
html { background: var(--surface-page); min-height: 100%; }
body { margin: 0; color: var(--text-strong); font-family: var(--font-sans); }
h1, h2, p { margin: 0; }

.admin { padding: 24px; display: flex; flex-direction: column; gap: 24px; max-width: 1024px; }

/* top bar = DS AdminBar (Figma page `admin` → `admin bar`, decision 0089). Mobile menu: a full-screen native modal
   dialog with a MenuLayer, like the shop's .site-menu (apps/storefront/base.css). */
.admin-menu {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; color: var(--text-strong);
  background: var(--surface-page);   /* surface-accent (the MenuLayer fill) is translucent in the backend mode: page under it = the page look */
}
.admin-menu:not([open]) { display: none; }
.admin-menu::backdrop { background: var(--surface-page); }
.admin-menu:focus { outline: none; }   /* programmatic focus target (decision 0043) */
/* lists on mobile: DS ListingRow in a plain <ul> (Figma Listings - mobile) */
.admin-rows { list-style: none; margin: 0; padding: 0; }
.admin-rows__empty { padding: 16px 0; }

/* Figma BACKEND → Create (2026-11-10): the frame is a 12-column grid, gap 16; main = 8 columns, side = 4 (fill).
   Create / edit and Listings (0163) are full width (Gio); the other admin pages keep max-width 1024. */
.admin:has(.admin-page) { max-width: none; }
.admin:has(.admin-listings) { max-width: none; }   /* Listings full width, more columns (Gio 2026-11-23, decision 0163) */
.admin-page { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-main { grid-column: span 8; }
.admin-side { grid-column: span 4; }
.admin-main { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.admin-side { display: flex; flex-direction: column; gap: 24px; }
/* Create / edit on desktop: the two columns scroll independently, each to its own end (Gio, 2026-11-12). The page is
   exactly the window: top bar, then the grid row fills the rest and each column has its own scroll. The bottom 24px of
   the frame padding moves inside the columns, so content runs to the window edge while scrolling and still ends 24px
   above it. The 4px padding cancelled by the margin keeps focus rings unclipped; position: relative keeps absolutely
   positioned helpers (e.g. visually hidden statuses) inside the scroll, or they would stretch the page. Mobile: one column, the page scrolls. */
.admin-page--attribute > .admin-side { position: sticky; top: 24px; }
.admin:has(.admin-page--edit) { height: 100vh; height: 100dvh; padding-bottom: 0; }
.admin-page--edit { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
.admin-page--edit > .admin-main, .admin-page--edit > .admin-side { position: relative; min-height: 0; overflow-y: auto; margin: -4px -4px 0; padding: 4px 4px 24px; }

.admin-section { display: flex; flex-direction: column; gap: 16px; }
/* Figma Create → `custom title` (0111): field, then From Discogs at its own width, gap 16 */
.admin-custom-title { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.admin-custom-title > :first-child { align-self: stretch; }
.admin-stack { display: flex; flex-direction: column; gap: 24px; }           /* Figma: Frame 1 / list, gap 24 */

.admin-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-row--tight { row-gap: 8px; }                                           /* Figma `label row`: gap-y 8 */
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .col-8 { grid-column: 8; }
.span-4.row-start { grid-column: 1 / span 4; }                                       /* a new grid row (Figma: checkbox rows under Label) */

.admin-status { min-height: 16px; }
.admin-status--error { color: var(--text-alert); }

/* sign-in (no Figma frame yet) and listings (Figma BACKEND → Listings) */
.admin-signin { max-width: 315px; display: flex; flex-direction: column; gap: 16px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 16px 8px 0; border-bottom: 1px solid var(--border-divider-strong); vertical-align: middle; }
.admin-table th:last-child, .admin-table td:last-child { padding-right: 0; }
.admin-table th { font-weight: 400; color: var(--text-moderate); }
.admin-table td.num, .admin-table th.num { font-variant-numeric: tabular-nums; }
.admin-table a { color: inherit; }
/* Figma BACKEND → Listings (2026-11-10): first column = row selection (checkbox label=false), price right-aligned */
.admin-table .select { width: 24px; }
.admin-table .select .hm-checkbox { display: flex; }
.admin-table .thumb { width: 40px; }   /* Figma: `product image` 40 × 40 column after the checkbox (decision 0123) */
.admin-table .thumb .hm-thumbnail { display: block; }
.admin-table .price { text-align: right; }
.admin-table .handle { width: 24px; }   /* Figma `listings table row` → `drag handle` 24, first column (decision 0129) */
.admin-table .handle .hm-drag-handle { display: flex; }
/* columns (Figma `listings table row`, decision 0163): fixed widths as in Figma, Record takes the rest; genre on one line */
.admin-table .status { width: 112px; } .admin-table .section { width: 72px; } .admin-table .price { width: 72px; }
.admin-table .format { width: 48px; } .admin-table .year { width: 48px; } .admin-table .grading { width: 96px; } .admin-table .photos { width: 56px; } .admin-table .samples { width: 64px; }
.admin-table .genre { width: 160px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-table .photos, .admin-table .samples { text-align: right; }
.admin-table__missing { color: var(--text-moderate); }
/* reorderable rows (useDragOrder, decision 0129): the others slide to the preview; the dragged one covers them on the
   page ground (FileList uses surface/base on its white panel; here the list sits on surface/page) */
.admin-sortable > [data-key] { transition: transform 150ms ease-out; }
.admin-sortable > [data-dragged] { position: relative; z-index: 1; transition: none; background: var(--surface-page); }
@media (prefers-reduced-motion: reduce) { .admin-sortable > [data-key] { transition: none; } }
.admin-listings { gap: 24px; }
/* Drafts filter column (Figma BACKEND → Listings → `drafts filters`, decision 0162): 200 wide, gap 24 to the list;
   the list keeps the bulk bar and the table, gap 24 as the page */
.admin-listings__body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-listings__list { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
/* bulk bar: always rendered, fixed height (38 button + 2×8), so selecting never moves the table */
.admin-bulk { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 8px 16px; background: var(--surface-subtle); }
.admin-bulk__count { flex: 1 1 auto; }
.admin-bulk__actions, .admin-bulk__message { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.admin-bulk__message[hidden] { display: none; }

/* Figma BACKEND → Content (decision 0106): list = groups (gap 24; head + rows, gap 8); editor form column 480
   (Memo), 640 for the page sections (Content - desktop · Shipping); links gap 16, sections gap 24 */
.admin-content { gap: 24px; }
.admin-content__group { display: flex; flex-direction: column; gap: 8px; }
.admin-content__form { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.admin-content__form:has(.admin-content__sections) { max-width: 640px; }
.admin-content__list { display: flex; flex-direction: column; gap: 16px; }
.admin-content__sections { gap: 24px; }
.admin-content__problems { margin: 0; padding-left: 20px; }

@media (max-width: 959px) {
  /* Figma page `admin` (decision 0089): the AdminBar bleeds to the screen edges, the page content keeps 16 */
  .admin { padding: 0 16px 16px; }
  .admin > .hm-admin-bar { margin: 0 -16px; }
  /* status tabs: one row that scrolls sideways (the last tab is cut at the edge, so it reads as more) */
  .admin .hm-tabs { overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  .admin .hm-tabs > * { flex: none; }
  .admin-page { grid-template-columns: minmax(0, 1fr); }
  .admin-main, .admin-side { grid-column: auto; }
  /* the side (SKU, status, preview) follows the form; the actions are in the ActionBar at the bottom */
  .admin-page > .hm-action-bar { grid-column: 1 / -1; margin: 0 -16px -16px; }
  html:has(.hm-action-bar) { scroll-padding-bottom: 88px; }   /* the bar (16 + 38 + 16 + 1) + a gap: a focused field is never under it */
  /* bulk bar: after the rows; while something is selected it stays at the bottom of the viewport (Figma `bulk bar`) */
  .admin-bulk { min-height: 0; padding: 0; background: none; }
  .admin-bulk:not(:has(.admin-bulk__actions)) .admin-bulk__count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .admin-bulk:has(.admin-bulk__actions) {
    position: sticky; bottom: 0; z-index: 2; margin: 0 -16px -16px;
    flex-direction: column; align-items: stretch; gap: 8px; padding: 16px;
    background: var(--surface-base); border-top: 1px solid var(--border-divider-strong);
  }
  .admin-bulk__actions { justify-content: flex-start; }
  .admin-page--attribute > .admin-side { position: static; }
  .admin:has(.admin-page--edit) { height: auto; padding-bottom: 16px; }
  .admin-page--edit { grid-template-rows: none; }
  .admin-page--edit > .admin-main, .admin-page--edit > .admin-side { overflow: visible; margin: 0; padding: 0; }
  .admin-row { grid-template-columns: minmax(0, 1fr); }
  .admin-row > *, .admin-row > .row-start { grid-column: 1 / -1; }   /* .row-start (1 / span 4) would add implicit columns to the 1-column grid and squeeze Label next to Country */
}
/* Figma `uploaded list` in Samples overview (2095:19476): rows with a title field, gap 16 */
.admin-samples { gap: 16px; }

/* Figma BACKEND → Create › side › preview (decision 0030): the PDP - mobile `pdp content`, in the shop theme
   (data-theme="frontend" = the frame's explicit Figma mode). Same values as apps/storefront/pdp.css (mobile):
   padding-x page-margin/mobile, padding-top small, padding-bottom 24 (literal, see open.md), row gap small,
   the gallery bleeds into the margins and the frame clips it (second image peeks). */
.admin-preview__shop {
  display: grid; grid-template-columns: minmax(0, 1fr); row-gap: var(--small);
  padding: var(--small) var(--page-margin-mobile) 24px;
  background: var(--surface-accent); color: var(--text-strong);
  overflow: hidden;
}
.admin-preview__shop .hm-gallery { --hm-gallery-bleed: var(--page-margin-mobile); }

/* Figma BACKEND → Attributes (2123:2053, decision 0034): list = Listings grammar + a toolbar (search fill, button hug,
   gap 16); entity page = the Create layout (main 8 + side 4) but in a 1024 frame, like Listings. */
.admin-toolbar { display: flex; gap: 16px; align-items: flex-start; }
.admin-toolbar__search { flex: 1 1 auto; min-width: 0; }
.admin:has(.admin-page--attribute) { max-width: 1024px; }
/* genre / tag page (0168): form 5 · actions 3 · the records checklist 4 on the right, full width (Figma 2523:1736);
   the column stays in view and its list scrolls inside it */
.admin:has(.admin-page--records) { max-width: none; }
.admin-page--records > .admin-main { grid-column: span 5; }
.admin-page--records > .admin-side { grid-column: span 3; }
.admin-records { grid-column: span 4; min-width: 0; position: sticky; top: 24px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; margin: -4px; padding: 4px; }
@media (max-width: 959px) {
  .admin-page--records > .admin-main, .admin-page--records > .admin-side, .admin-records { grid-column: auto; }
  .admin-records { position: static; max-height: none; overflow: visible; margin: 0; padding: 0; }
}
.admin-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }   /* Figma `record list`, gap 8 */
.admin-links a { color: inherit; }

/* Figma BACKEND → Shipping (2201:4782, decision 0057): frame on surface/page like every admin page (0099);
   fields keep surface-accent over it. Sections of heading · help · table · Add, gap 16; column widths from the frame. */
.admin-shipping { display: flex; flex-direction: column; gap: 24px; }
.admin-shipping h1, .admin-shipping h2, .admin-shipping p { margin: 0; }
.admin-shipping .admin-toolbar { align-items: center; }
.admin-shipping__intro { flex: 1 1 auto; }
.admin-shipping__section { display: flex; flex-direction: column; gap: 16px; }
.admin-shipping__problems { margin: 0; padding-left: 20px; }
.admin-shipping__table { table-layout: fixed; }
.admin-shipping__table .hm-input { width: 100%; min-width: 0; }
.admin-shipping__w-name { width: 240px; }
.admin-shipping__w-select { width: 180px; }
.admin-shipping__w-weight { width: 200px; }
.admin-shipping__w-short { width: 120px; }
.admin-shipping__w-count { width: 72px; }
.admin-shipping__actions { width: 88px; white-space: nowrap; text-align: right; }
.admin-shipping__minimum { display: flex; align-items: center; }   /* Figma `minimum order` row: label column 280, field 200 */
.admin-shipping__minimum > label { width: 280px; }
.admin-shipping__minimum > .hm-input { width: 200px; }
.admin-shipping__check { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.admin-shipping__check > :first-child { width: 240px; }
.admin-shipping__check > :last-child { width: 400px; max-width: 100%; }
.admin-shipping p.admin-shipping__result { margin-top: 16px; white-space: pre-line; }
#shipping-zones td { vertical-align: top; }   /* Figma zones rows: top left (Gio 2026-11-12), the countries cell grows with its names */

/* Photo of the label (Create, decisions 0090 / 0092), the Discogs pickers (Create, Bulk review) and the Bulk rows /
   count line. The pickers' suggestions overlay what follows. */
.admin-photo { display: flex; flex-direction: column; gap: 8px; }
.admin-photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-photo__status { margin: 0; color: var(--text-moderate); }
.admin-photo__status:empty { display: none; }
.admin-count { display: flex; align-items: center; gap: 8px; color: var(--text-moderate); }
.admin-count > p { margin: 0; }
.admin-rows { list-style: none; margin: 0; padding: 0; }
.admin-picker { position: relative; display: flex; flex-direction: column; gap: 4px; }
.admin-picker > p { margin: 0; }
.admin-picker__list { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; max-height: 360px; overflow-y: auto; }

/* Shipping on mobile (decision 0089): the tables stack, one row = a block of fields, each with its column name
   above it (data-label, set in admin.js); the fixed desktop column widths are dropped. */
@media (max-width: 959px) {
  .admin-shipping .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-shipping__table, .admin-shipping__table tbody, .admin-shipping__table tr, .admin-shipping__table td { display: block; width: auto; }
  .admin-shipping__table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .admin-shipping__table tr { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--border-divider-strong); }
  .admin-shipping__table td { padding: 0; border: 0; text-align: left; }
  .admin-shipping__table td:empty { display: none; }
  .admin-shipping__table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--text-moderate); }
  .admin-shipping__minimum { flex-direction: column; align-items: stretch; gap: 4px; }
  .admin-shipping__minimum > label, .admin-shipping__minimum > .hm-input, .admin-shipping__check > :first-child { width: auto; }
}

/* Orders (Figma BACKEND → Orders, decision 0100): order page = the Create layout (main + side); details in two
   columns (Figma `details`: gap 16 × 32), one column on mobile */
.admin-order__records { display: flex; flex-direction: column; gap: 8px; }
.admin-order__records h2 { margin: 0; }
.admin-order__details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 16px; }
@media (max-width: 959px) { .admin-order__details { grid-template-columns: minmax(0, 1fr); gap: 24px; } }

/* Samples overview → Length + Duration of a sample (decision 0110; not in Figma yet, design/open.md): side by side, gap 16 like the sample row */
.admin-sample-clip { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.admin-sample-clip > * { flex: 0 1 200px; min-width: 0; }

/* sample player (Gio 2026-11-17): the shop's Player (packages/ui), docked to the bottom of the viewport as in the shop
   (apps/storefront/base.css .site-player, same placeholder motion). While it is open the page reserves its height and
   the mobile ActionBar sits right above it (--admin-player-height, set by admin.js). */
.admin-player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  transform: translateY(100%); visibility: hidden;
  transition: transform 200ms ease-out, visibility 0s linear 200ms;
}
.admin-player[data-open] { transform: none; visibility: visible; transition: transform 200ms ease-out; }
@media (prefers-reduced-motion: reduce) { .admin-player, .admin-player[data-open] { transition: none; } }
body[data-player-open] { padding-bottom: var(--admin-player-height, 0px); }
body[data-player-open] .hm-action-bar { bottom: var(--admin-player-height, 0px); }
/* backend theme: surface/accent is black-a4 (translucent), so the player gets the admin's bar ground, like the
   ActionBar and the bulk bar (decision 0099: bars and dialogs stay surface/base) */
.admin-player .hm-player { background: var(--surface-base); }

/* Back to the list, above the title on Edit listing */
.admin-main > .hm-back-link { margin-bottom: 8px; }

/* Figma BACKEND → Dashboard (decision 0169): sections 40 apart; a section = head (title, period tabs) + stats, gap 16.
   Stats: 4 columns, gap 24 (desktop frame 976 = 4 × 226 + 3 × 24); one column, gap 16, on mobile. */
.admin-dashboard { display: flex; flex-direction: column; gap: 40px; }
.admin-dashboard > h1 { margin: 0; }
.admin-dashboard__section { display: flex; flex-direction: column; gap: 16px; }
.admin-dashboard__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.admin-dashboard__head > h2 { margin: 0; }
.admin-dashboard__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; align-items: start; }
@media (max-width: 959px) {
  .admin-dashboard__head { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; }
  .admin-dashboard__head > .hm-tabs { align-self: stretch; }   /* the tabs scroll sideways, as on the other admin pages */
  .admin-dashboard__stats { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
/* Collections (Figma BACKEND → Collections, decision 0174): the support line beside New collection; table columns as
   the `collection row` (Name 240, On home 96, Records right) */
.admin-toolbar--support { align-items: center; }
.admin-toolbar--support > p { flex: 1 1 auto; margin: 0; color: var(--text-strong); }
.admin-collections .name { width: 240px; }
.admin-collections .on-home { width: 96px; }
/* video of a sample (0180): Video image select + Download video, below Length */
.admin-sample-video { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.admin-sample-video > :first-child { flex: 0 1 240px; min-width: 0; }

/* Settings → Records per page (Figma `number setting`, decision 0179): the field is 120 wide */
.admin-settings__number { width: 120px; }
