

.contact-form,
.editor-form {
  display: grid;
  gap: 12px;
}

.editor-section {
  display: grid;
  gap: 14px;
}

.editor-section h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
}

.editor-preview {
  width: 180px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  border: 1px solid var(--line);
  background: rgba(251, 248, 240, 0.92);
  padding: 14px;
  backdrop-filter: blur(14px);
}

/* Force viewport-centering explicitly rather than relying on the browser's default
   <dialog> auto-margin centering, which can land off-center on a scrolled page. */
.product-dialog[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  margin: 0;
  transform: translate(-50%, -50%);
}

.dialog-frame {
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -18px -18px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  padding: 20px 24px;
  backdrop-filter: blur(14px);
}

.dialog-head h2 {
  max-width: 760px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-title {
  display: grid;
  gap: 4px;
  padding-right: 100px;
}

/* Dialogs whose title block isn't wrapped in .dialog-title still need room
   reserved so their heading text never runs under the floating close X. */
.dialog-head > div:not(.dialog-title) {
  padding-right: 56px;
}

.dialog-float-actions {
  position: sticky;
  top: 12px;
  z-index: 5;
  height: 0;
  overflow: visible;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  pointer-events: none;
}

@media (max-width: 520px) {
  .results-bar {
    align-items: stretch;
  }

  .view-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .view-toggle-btn {
    flex: 1 1 0;
  }

  .admin-menu {
    grid-template-columns: 1fr;
  }

  .admin-table {
    min-width: 760px;
  }

  .row-actions .primary-btn,
  .row-actions .secondary-btn,
  .row-actions .danger-btn,
  .row-actions form {
    width: 100%;
  }

  .inline-status-form,
  .filter-actions {
    width: 100%;
  }

  .dialog-head h2 {
    white-space: normal;
  }
}

/* ==========================================================================
   Admin modern theme — scoped to body:has(.admin-shell) only, same colour tokens.
   Flat, low-chrome surfaces (no stacked boxes): one hairline + soft shadow
   per surface instead of borders-within-borders.
   ========================================================================== */

/* Vars live on :root (not .admin-shell) because admin dialogs render as siblings of
   <main class="admin-shell"> in the DOM, not descendants — custom properties only
   inherit down the tree, so scoping them to body:has(.admin-shell) would leave dialogs unstyled. */
:root {
  --admin-radius: 12px;
  --admin-radius-sm: 8px;
  --admin-card: #f8fafc;
  --admin-panel: #f1f5f9;
  --admin-hairline: rgba(15, 23, 42, 0.11);
  --admin-shadow-sm: 0 1px 2px rgba(25, 20, 13, 0.04);
  --admin-shadow-md: 0 8px 24px rgba(25, 20, 13, 0.07);
  --admin-shadow-lg: 0 24px 60px rgba(25, 20, 13, 0.16), 0 6px 18px rgba(25, 20, 13, 0.08);
}

body:has(.admin-shell) .dialog-head .eyebrow + h2,
body:has(.admin-shell) .dialog-title h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Dialogs — modern card, sticky/floating footer, top-right close */
body:has(.admin-shell) .product-dialog {
  border: none;
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow-lg);
}

body:has(.admin-shell) .dialog-head {
  border-radius: var(--admin-radius) var(--admin-radius) 0 0;
  border-bottom: 1px solid var(--admin-hairline);
  background: var(--admin-card);
}

body:has(.admin-shell) .sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -18px -18px;
  border: none;
  border-top: 1px solid var(--admin-hairline);
  border-radius: 0 0 var(--admin-radius) var(--admin-radius);
  background: var(--admin-panel);
  box-shadow: 0 -8px 20px rgba(25, 20, 13, 0.05);
}

body:has(.admin-shell) .editor-section input,
body:has(.admin-shell) .editor-section select,
body:has(.admin-shell) .editor-section textarea {
  border-radius: 8px;
  border-color: var(--admin-hairline);
}

body:has(.admin-shell) .product-dialog .dialog-title {
  padding-right: 0;
}

body:has(.admin-shell) .product-dialog .editor-section {
  border-top: 1px solid var(--admin-hairline);
  padding-top: 16px;
}

/* Breathing room before the floating save FAB / footer — otherwise the last
   field/section sits flush against it, reading as cut off. .editor-section
   elements actually live inside .editor-tab-body (not as a direct child of
   .dialog-frame, which the old selector here assumed and so never matched),
   so pad the tab body itself; non-tabbed editor dialogs pad their last
   .editor-section directly via the shared rule below. */
body:has(.admin-shell) .product-dialog .editor-tab-body {
  padding-bottom: 92px;
}

body:has(.admin-shell) .product-dialog .dialog-head + .editor-section {
  border-top: 0;
}

/* The manage-products-dialog layout (used by both "Select products" and the resume picker)
   already pads its scrolling .dialog-body by 24px — the generic .editor-section top
   border/padding above was stacking on top of that for whichever section comes first,
   reading as an oversized gap right under the header. */
body:has(.admin-shell) .manage-products-dialog .dialog-body > .editor-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.editor-tab-btn {
  padding: 9px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.editor-tab-btn:hover {
  color: var(--ink);
}

.editor-tab-btn.is-active {
  border-color: var(--line);
  background: var(--surface, #fff);
  color: var(--ink);
}

body:has(.admin-shell) .product-dialog .editor-tab-panel {
  border-top: 0;
  padding-top: 16px;
}

/* Manage-products popup (collections page): remove/reassign + add, in one dialog */
/* This dialog skips the usual .dialog-frame wrapper (it needs its body, not the
   whole dialog, to scroll so the header/Done button stay reachable) — so it's
   made a flex column here with .dialog-body as the only scrolling region. */
.manage-products-dialog {
  width: min(760px, calc(100% - 28px));
}

/* display:flex must only apply once open — setting it unconditionally overrides
   the browser's default `dialog:not([open]) { display: none }`, which is what was
   making this dialog render as permanent, always-visible page content. */
.manage-products-dialog[open] {
  display: flex;
  flex-direction: column;
}

.manage-products-dialog .dialog-head {
  position: static;
  flex: 0 0 auto;
  margin: 0;
}

.manage-products-dialog .dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 24px;
  padding: 24px;
}

.manage-products-dialog .sticky-actions {
  position: static;
  flex: 0 0 auto;
  /* This dialog has no .dialog-frame wrapper (its .dialog-body already handles its own 24px
     padding), so the -18px margin above — meant to counteract that wrapper's padding — would
     instead push this bar past the dialog's own rounded/clipped edge, cutting off the padding
     around its last button (e.g. Cancel reading as flush against the corner). */
  margin: 0;
  padding: 14px 24px;
}

/* Floating dialog controls — the close X always pins to the dialog's top-right
   corner (pulled out of the header's flex flow so a long title or a narrow
   viewport can never wrap it away or push it off-screen), and the primary
   save/create action becomes a small round floating button pinned to the
   bottom-right instead of a full-width sticky bar. Both are positioned
   relative to the nearest positioned ancestor — .dialog-head (sticky) for the
   close button, so it stays with the header as it sticks during scroll — and
   both work unchanged inside the mobile full-screen dialog overrides since
   those only resize the dialog box, not this positioning. */
.dialog-close-float {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(20, 16, 12, 0.08);
  color: var(--ink, #1c1c1c);
  cursor: pointer;
}

.dialog-close-float:hover {
  background: rgba(20, 16, 12, 0.16);
}

.dialog-close-float svg {
  width: 16px;
  height: 16px;
}

/* Positioned relative to .product-dialog itself (a sibling of .dialog-frame,
   not nested inside it) rather than sticky within the scrollable content.
   Sticky-inside-a-scroll-container turned out fragile: it interacted badly
   with the dialog's own fit-content sizing and could render partially
   clipped or need an extra nudge-scroll to fully reveal. Living outside
   .dialog-frame means it's never affected by that container's scroll
   position, height, or overflow at all — it just floats at a fixed spot in
   the dialog's own box, matching how .dialog-close-float is anchored. */
.dialog-fab-row {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  pointer-events: none;
}

.dialog-save-fab {
  pointer-events: auto;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--ink, #1c1c1c);
  color: #fff;
  box-shadow: 0 10px 24px rgba(20, 16, 12, 0.32);
  cursor: pointer;
}

.dialog-save-fab:hover {
  opacity: 0.9;
}

.dialog-save-fab:disabled {
  opacity: 0.6;
  cursor: default;
}

.dialog-save-fab svg {
  width: 22px;
  height: 22px;
}

/* Non-tabbed editor dialogs (FAQ, trade code, custom order, enquiry
   regenerate/convert) keep their single .editor-section as the last visible
   child of .editor-form — give it the same clearance so the floating FAB
   never sits on top of the last field. */
.editor-form > .editor-section:last-of-type {
  padding-bottom: 92px;
}

/* Read-only dialogs (e.g. the product view dialog) keep the old full-width
   .sticky-actions bar instead of a floating FAB — give their last section
   the same clearance so it doesn't sit flush against/under that bar. */
.dialog-frame > section:last-of-type {
  padding-bottom: 80px;
}

.media-field-group h4,
.editor-tab-panel h4 {
  margin: 0;
  font-size: 0.95rem;
}

/* Responsive polish for the admin shell specifically */
@media (max-width: 760px) {
  body:has(.admin-shell) .admin-page-head {
    gap: 10px;
  }

  body:has(.admin-shell) .admin-sidebar {
    padding: 12px;
  }

  body:has(.admin-shell) .admin-brand-row {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  body:has(.admin-shell) .admin-brand {
    min-width: 0;
  }

  body:has(.admin-shell) .admin-brand > span:last-child {
    min-width: 0;
    overflow: hidden;
  }

  body:has(.admin-shell) .admin-brand strong,
  body:has(.admin-shell) .admin-brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:has(.admin-shell) .admin-sidebar-collapsed .admin-sidebar {
    gap: 0;
    padding: 10px 12px;
  }

  body:has(.admin-shell) .admin-sidebar-collapsed .admin-brand-row {
    justify-content: space-between;
  }

  body:has(.admin-shell) .admin-sidebar-collapsed .admin-brand {
    display: inline-flex;
  }

  body:has(.admin-shell) .admin-sidebar-collapsed .admin-brand span:last-child,
  body:has(.admin-shell) .admin-sidebar-collapsed .tooltip-anchor,
  body:has(.admin-shell) .admin-sidebar-collapsed .admin-menu,
  body:has(.admin-shell) .admin-sidebar-collapsed .admin-sidebar form {
    display: none;
  }

  body:has(.admin-shell) .admin-sidebar:not(:has(+ *)) {
    border-bottom: 0;
  }

  body:has(.admin-shell) .admin-menu {
    padding-top: 12px;
  }

  body:has(.admin-shell) .admin-menu a {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:has(.admin-shell) .admin-page-head h1 {
    font-size: 1.3rem;
  }

  body:has(.admin-shell) .row-actions {
    min-width: 0;
  }

  /* Product rows stack into cards on mobile — each field goes on its own line rather than
     forcing horizontal scroll, since .product-row is CSS grid, not a real <table>.
     .product-row-head shares the .product-row class (same grid), so its "display: none"
     must come after the shared rule below to win the cascade tie-break. */
  .product-row {
    position: relative;
    display: block;
    margin: 10px 16px;
    border: 1px solid var(--admin-hairline, var(--line));
    border-radius: var(--admin-radius-sm, 8px);
    background: var(--admin-card, #f8fafc);
    padding: 0;
    overflow: hidden;
  }

  .product-row-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    padding: 0;
    border-bottom: none;
    z-index: 2;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    padding: 4px;
  }

  .product-row-head {
    display: none;
  }

  .product-row > * {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-bottom: 1px solid var(--admin-hairline, #e2d9cc);
    box-sizing: border-box;
  }

  .product-row > *:last-child {
    border-bottom: none;
  }

  .product-row > [data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--muted);
  }

  .product-action-grid {
    grid-template-columns: repeat(4, 34px);
    justify-content: flex-start;
  }

  body:has(.admin-shell) .collection-chip {
    max-width: 140px;
  }

  body:has(.admin-shell) .product-admin-detail {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  body:has(.admin-shell) .product-admin-detail dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Full-width on phones/tablets, but height fits content (capped at the
     viewport) instead of always forcing 100vh — a 3-field dialog like "New
     Trade Code" shouldn't stretch to full-screen height with empty space and
     an unnecessary scrollbar. Centering via inset:0 + margin:auto (rather
     than the desktop top/left 50% + translate(-50%,-50%) transform) keeps
     both axes symmetric on their own terms instead of combining inconsistently
     with a percentage width/height, which previously could leave 0 top/bottom
     inset but nonzero left/right (or vice versa) depending on rounding. */
  body:has(.admin-shell) .product-dialog[open] {
    inset: 0;
    margin: auto;
    transform: none;
  }

  body:has(.admin-shell) .product-dialog {
    width: 100%;
    max-width: 100%;
    /* NOT "height: auto" — with inset:0 on a fixed element, "auto" height
       triggers the CSS stretch-to-fill algorithm (top+bottom both set) and
       the dialog stretches to the full viewport regardless of content.
       "fit-content" opts back into intrinsic (content-based) sizing, same
       as how the native <dialog> UA stylesheet sizes itself by default. */
    height: fit-content;
    max-height: 100vh;
    border-radius: 0;
  }

  body:has(.admin-shell) .dialog-head,
  body:has(.admin-shell) .sticky-actions {
    border-radius: 0;
  }

  body:has(.admin-shell) .sticky-actions {
    flex-direction: column-reverse;
  }

  body:has(.admin-shell) .sticky-actions .primary-btn,
  body:has(.admin-shell) .sticky-actions .secondary-btn,
  body:has(.admin-shell) .sticky-actions .danger-btn {
    width: 100%;
  }
}

.product-dialog.share-dialog {
  width: min(480px, calc(100% - 28px));
}

.share-field {
  display: grid;
  gap: 6px;
}

.share-field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.share-field-row {
  display: flex;
  gap: 8px;
}

.share-field-row input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: "Courier New", monospace;
}

.share-field-row .secondary-btn {
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  .share-field-row {
    flex-wrap: wrap;
  }

  .share-field-row input {
    flex-basis: 100%;
  }

  .share-field-row .secondary-btn {
    flex: 1 1 auto;
  }
}