/*
 * Page-level styles that are not part of the Vireo port.
 * Anything reusable belongs in vireo-theme.css instead.
 */

/* Audit log values: long JSON blobs must not stretch the table. */
.rx-audit-value { max-width: 34ch; overflow-wrap: anywhere; font-size: 0.8125rem; }
.rx-audit-value.rx-audit-old { color: var(--rx-text-muted); text-decoration: line-through; }
.rx-audit-value.rx-audit-new { color: var(--rx-text-strong); }

/* Permission checkbox grid in the role editor. */
.rx-perm-group + .rx-perm-group { margin-top: 1.5rem; }
.rx-perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.5rem 1.5rem; }

/* Session rows on the account page. */
.rx-session-row { border: 1px solid var(--rx-border); border-radius: var(--rx-radius-md); padding: 12px 14px; }
.rx-session-row.rx-session-current { border-color: var(--rx-accent); background: var(--rx-accent-wash); }

.rx-resend[disabled] { opacity: 0.6; }

/* Deploy self-test panel on the dashboard. */
.rx-selftest-fail { border-color: color-mix(in srgb, var(--rx-danger) 50%, transparent) !important; }
.rx-selftest-list { margin: 0; padding-left: 1.1rem; font-size: 0.8125rem; }
.rx-selftest-list code { overflow-wrap: anywhere; }

/* =====================================================================
   Phase 2 — taxonomy tree, spec templates, sync matrix
   ===================================================================== */

/* Taxonomy tree. Nested <ul> with a guide line down each level. */
.rx-tree { list-style: none; margin: 0; padding: 0; }
.rx-tree .rx-tree { margin-left: 18px; padding-left: 12px; border-left: 1px solid var(--rx-border); }
/* An empty list still needs height, or there is nowhere to drop a first child. */
.rx-tree-empty { min-height: 12px; }
.rx-tree-item { list-style: none; }

.rx-tree-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--rx-radius-md);
  transition: background var(--rx-motion);
}
.rx-tree-row:hover { background: var(--rx-surface-subtle); }
.rx-tree-row.rx-tree-selected { background: var(--rx-accent-wash); }
.rx-tree-row.rx-tree-selected .rx-tree-name { color: var(--rx-accent); }
.rx-tree-row.rx-tree-inactive .rx-tree-name { color: var(--rx-text-subtle); text-decoration: line-through; }

.rx-tree-name { color: var(--rx-text); text-decoration: none; font-weight: 500; }
.rx-tree-name:hover { color: var(--rx-text-strong); }
.rx-tree-handle { cursor: grab; color: var(--rx-text-subtle); display: inline-flex; }
.rx-tree-handle:active { cursor: grabbing; }
.rx-tree-ghost > .rx-tree-row { opacity: 0.4; background: var(--rx-accent-wash); }
.rx-tree-busy { opacity: 0.6; pointer-events: none; }

.rx-path { overflow-wrap: anywhere; }

/* A row that is present but not editable here (inherited, inactive). */
.rx-row-muted > td { opacity: 0.65; }
/* An import row's warnings, beneath the row they belong to. Tinted so it reads
   as attached to the block above rather than as another row of its own. */
.rx-row-warn > td {
  border-top: 0;
  padding-top: 0;
  background: color-mix(in srgb, var(--rx-warning) 7%, transparent);
}

.rx-scroll-160 { max-height: 160px; overflow-y: auto; padding-right: 4px; }

/* Sync matrix. The first column and the header row both stay put while scrolling. */
.rx-matrix-scroll { max-height: 70vh; overflow: auto; }
.rx-matrix { border-collapse: separate; border-spacing: 0; }
.rx-matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--rx-surface-subtle);
  vertical-align: bottom;
}
.rx-matrix-corner { position: sticky; left: 0; z-index: 4 !important; min-width: 220px; }
.rx-matrix-row-head {
  position: sticky; left: 0; z-index: 2;
  background: var(--rx-surface);
  font-weight: 500; white-space: nowrap;
  border-right: 1px solid var(--rx-border);
}
.rx-matrix-row-head a { color: var(--rx-text); text-decoration: none; }
.rx-matrix-row-head a:hover { color: var(--rx-accent); }
.rx-matrix-head { min-width: 108px; max-width: 108px; padding-bottom: 8px !important; }
/* The theme uppercases and letter-spaces every thead cell, which turns a
   multi-word field label into an unreadable column. Opt these out. */
.rx-matrix thead th {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.75rem;
  color: var(--rx-text-muted);
}
.rx-matrix-head-inner { display: block; line-height: 1.3; white-space: normal; }
.rx-matrix-head-inner .rx-meta { text-transform: lowercase; font-size: 0.6875rem; margin-top: 2px; }
.rx-matrix-corner { text-transform: none !important; letter-spacing: normal !important; }
.rx-matrix-cell { text-align: center; padding: 4px !important; }

.rx-cell {
  width: 30px; height: 30px; border-radius: var(--rx-radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rx-border); background: var(--rx-surface-subtle);
  color: var(--rx-text-subtle); cursor: pointer;
  transition: all var(--rx-motion);
}
.rx-cell:hover:not([disabled]) { border-color: var(--rx-border-strong); color: var(--rx-text-strong); }
.rx-cell[disabled] { cursor: not-allowed; opacity: 0.45; }
.rx-cell-on { background: color-mix(in srgb, var(--rx-success) 18%, transparent); border-color: color-mix(in srgb, var(--rx-success) 50%, transparent); color: var(--rx-success); }
.rx-cell-off { background: color-mix(in srgb, var(--rx-danger) 14%, transparent); border-color: color-mix(in srgb, var(--rx-danger) 45%, transparent); color: var(--rx-danger); }
/* Inherited cells stay quiet but still show which way they resolve. */
.rx-cell-inherit.rx-cell-effective-on { color: var(--rx-success); }
.rx-cell-inherit:not(.rx-cell-effective-on) { color: var(--rx-text-subtle); }

.rx-cell-key { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; border: 1px solid var(--rx-border); }
.rx-cell-key.rx-cell-on { background: color-mix(in srgb, var(--rx-success) 35%, transparent); }
.rx-cell-key.rx-cell-off { background: color-mix(in srgb, var(--rx-danger) 30%, transparent); }
.rx-cell-key.rx-cell-inherit { background: var(--rx-surface-subtle); }
.rx-cell-key.rx-cell-scope { background: repeating-linear-gradient(45deg, var(--rx-border-strong) 0 2px, transparent 2px 4px); }

/* Metafield list: keep the scope column from pushing the actions out of view. */
.rx-scope-cell { white-space: nowrap; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }

/* --- Products: list, profile, media ------------------------------------- */

/* Drag-to-sort rows (features, in the box, specs, galleries). */
.rx-sort-handle { cursor: grab; display: inline-flex; align-items: center; }
.rx-sort-handle:active { cursor: grabbing; }
.rx-sort-ghost { opacity: 0.4; background: var(--rx-accent-wash); }

/* Quill: the theme's own surface and border, not Quill's defaults. */
.rx-quill { min-height: 220px; background: var(--rx-surface); }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--rx-border) !important; }
.ql-toolbar.ql-snow { border-radius: var(--rx-radius-md) var(--rx-radius-md) 0 0; background: var(--rx-surface-subtle); }
.ql-container.ql-snow { border-radius: 0 0 var(--rx-radius-md) var(--rx-radius-md); font-family: var(--rx-font-sans); font-size: 0.9375rem; }
.ql-editor { color: var(--rx-text); min-height: 200px; }
.ql-editor.ql-blank::before { color: var(--rx-text-subtle); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--rx-text-muted); }
.ql-snow .ql-fill { fill: var(--rx-text-muted); }
.ql-snow .ql-picker-label { color: var(--rx-text-muted); }
.ql-snow .ql-picker-options { background: var(--rx-surface-overlay); border-color: var(--rx-border) !important; }
.ql-snow .ql-active .ql-stroke { stroke: var(--rx-accent) !important; }
.ql-snow .ql-active .ql-fill { fill: var(--rx-accent) !important; }

/* Media grid. Cards are a fixed width so reordering does not reflow the page. */
.rx-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rx-media-card { border: 1px solid var(--rx-border); border-radius: var(--rx-radius-md); overflow: hidden; background: var(--rx-surface-subtle); }
.rx-media-thumb { position: relative; aspect-ratio: 1; background: var(--rx-canvas); }
.rx-media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.rx-media-badge { position: absolute; top: 6px; left: 6px; }
.rx-media-handle { position: absolute; top: 4px; right: 4px; padding: 4px; border-radius: var(--rx-radius-xs); background: var(--rx-surface-overlay); color: var(--rx-text-muted); }

.rx-thumb { border-radius: var(--rx-radius-sm); object-fit: contain; background: var(--rx-canvas); border: 1px solid var(--rx-border); }
.rx-thumb-sm { border-radius: var(--rx-radius-xs); object-fit: contain; background: var(--rx-canvas); flex-shrink: 0; }

/* Upload drop target. */
.rx-dropzone {
  border: 1px dashed var(--rx-border-strong); border-radius: var(--rx-radius-md);
  padding: 24px 16px; text-align: center; color: var(--rx-text-muted);
  transition: border-color var(--rx-motion), background var(--rx-motion);
}
.rx-dropzone-active { border-color: var(--rx-accent); background: var(--rx-accent-wash); }
.rx-upload-status:empty { display: none !important; }

/* Import report: a long before/after cell should wrap, not stretch the table. */
.rx-diff-cell { max-width: 30ch; overflow-wrap: anywhere; font-size: 0.8125rem; }
.rx-report-scroll { max-height: 60vh; overflow: auto; }

/* The inherit/on/off control needs room: a select squeezed to one character
   reads as nothing at all. */
.rx-override-form { min-width: 11.5rem; }
.rx-override-form .form-select { min-width: 7rem; }

/* A spec row is value + unit + label override in one input group. Minimum
   widths make it wrap onto a second line on a phone instead of shrinking every
   field into uselessness. */
.rx-spec-value { min-width: 7rem; }
.rx-spec-label { min-width: 10rem; max-width: 12rem; }

/* A dashboard number that is also a link should look like one on hover. The
   colour is left alone so a toned card (a mismatch waiting on a decision)
   keeps saying what it says. */
a.rx-kpi { text-decoration: none; }
a.rx-kpi:hover { text-decoration: underline; text-underline-offset: 3px; }

/* A pending migration is a warning, not a failure: the app still works, a
   feature is just waiting. Amber border to match what the text says. */
.rx-notice-warn { border-color: color-mix(in srgb, var(--rx-warning) 50%, transparent) !important; }

/* --------------------------------------------------------------------
   Charts (PLAYBOOK 4.6)
   -------------------------------------------------------------------- */
/* The height is set here rather than per chart so a chart that fails to
   render leaves a hole of the right size instead of collapsing the layout. */
.rx-chart { min-height: 220px; }
.rx-chart-sm { min-height: 140px; }
.rx-chart-tall { min-height: 220px; }

/* ApexCharts draws its own text nodes; keep them on the theme's ink rather
   than the series colour, and off the library's hard-coded greys. */
.rx-chart .apexcharts-text,
.rx-chart .apexcharts-legend-text { fill: var(--rx-text-muted); color: var(--rx-text-muted) !important; }
.rx-chart .apexcharts-tooltip {
  background: var(--rx-surface-overlay) !important;
  border: 1px solid var(--rx-border) !important;
  box-shadow: var(--rx-shadow-card);
  color: var(--rx-text);
}
.rx-chart .apexcharts-tooltip-title {
  background: var(--rx-surface-subtle) !important;
  border-bottom: 1px solid var(--rx-border) !important;
  color: var(--rx-text-strong);
}
.rx-chart .apexcharts-gridline { stroke: var(--rx-chart-grid); }

/* ApexCharts paints the first heatmap legend marker from its own defaults
   rather than from that range's colour, which leaves the "not in this
   template" key as a white square — the loudest thing in a legend whose whole
   point is that it means nothing is there. Match it to the cells it stands for. */
#rx-specfill .apexcharts-legend-series:first-child .apexcharts-legend-marker path,
#rx-specfill .apexcharts-legend-series:first-child .apexcharts-legend-marker rect {
  fill: var(--rx-surface);
  stroke: var(--rx-border-strong);
  stroke-width: 1;
}

/* A row that needs attention without being an error: an out-of-date product on
   the push screen. Tinted, not coloured text — the badge carries the meaning. */
.rx-row-flagged > td { background: color-mix(in srgb, var(--rx-surface-subtle) 70%, transparent); }

/* The per-product diff on the review screen. */
.rx-diff { font-size: 0.8125rem; }
.rx-diff td { vertical-align: top; }
.rx-diff .rx-from { color: var(--rx-text-subtle); text-decoration: line-through; }
.rx-diff .rx-to { color: var(--rx-text-strong); }
.rx-diff pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 12rem; overflow: auto; }

/* ---------------------------------------------------------------------------
   Diagnose a failed push (sync/diagnose.php)
   A Shopify error is only useful in full, so nothing here clips: the blocks
   wrap and scroll instead of ending in an ellipsis.
--------------------------------------------------------------------------- */
.rx-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rx-text-subtle);
  margin-bottom: 0.5rem;
}
.rx-raw {
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24rem;
  overflow: auto;
  background: var(--rx-surface-subtle);
  border: 1px solid var(--rx-border);
  border-radius: 8px;
  padding: 0.625rem 0.75rem;
  margin: 0;
}
.rx-diff td .rx-raw { max-height: 12rem; }
.rx-payload {
  border: 1px solid var(--rx-border);
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
}
.rx-payload > summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.rx-payload[open] > summary { margin-bottom: 0.25rem; }
/* The failure cell on the batch screen. Full text, not an ellipsis: it scrolls
   inside the cell rather than hiding the part that names the cause. */
.rx-job-error {
  max-width: 44ch;
  max-height: 7rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   Layout utilities (Phase 6)

   These exist so no page needs a `style=` attribute. The CSP forbids inline
   styles, and an attribute is also the one place a value can be smuggled into
   a page, so every width, height and indent a template needs has a name here
   instead. Anything genuinely dynamic is set from JS through the CSSOM, which
   the CSP does not govern.
--------------------------------------------------------------------------- */

/* Column widths in characters, for truncated table cells. */
.rx-cw-14 { max-width: 14ch; }
.rx-cw-20 { max-width: 20ch; }
.rx-cw-22 { max-width: 22ch; }
.rx-cw-24 { max-width: 24ch; }
.rx-cw-26 { max-width: 26ch; }
.rx-cw-28 { max-width: 28ch; overflow-wrap: anywhere; }

/* Control widths. */
.rx-mw-5  { max-width: 5rem; }
.rx-mw-6  { max-width: 6rem; }
.rx-mw-7  { max-width: 7rem; }
.rx-mw-11 { max-width: 11rem; }
.rx-mw-14 { max-width: 14rem; }
.rx-mw-16 { max-width: 16rem; }
.rx-w-auto { width: auto; }

/* The checkbox column on every selectable list. */
.rx-col-check { width: 2.5rem; }

/* Progress bars: thin, and never a style attribute. A bar whose width is fixed
   gets a class; a bar that moves is driven from JS. */
.rx-progress-xs { height: 4px; }
.rx-progress-sm { height: 6px; }
.rx-bar-0 { width: 0; }
.rx-bar-full { width: 100%; }

/* A <summary> is a button in everything but name. */
.rx-summary { cursor: pointer; }

/* Tree indents on the sync matrix: one step per level, no inline padding. */
[data-rx-depth="1"] { padding-left: 14px; }
[data-rx-depth="2"] { padding-left: 28px; }
[data-rx-depth="3"] { padding-left: 42px; }
[data-rx-depth="4"] { padding-left: 56px; }
[data-rx-depth="5"] { padding-left: 70px; }
[data-rx-depth="6"] { padding-left: 84px; }
[data-rx-depth="7"] { padding-left: 98px; }
[data-rx-depth="8"] { padding-left: 112px; }

/* The brand slot (views/partials/brand.php). The mark is square, so it takes
   the place of the lettermark tile at the same size and the words stay beside
   it. The artwork draws its own rounded tile, so nothing here clips it. Remove
   assets/img/logo.svg and the CSS lettermark comes back. */
.rx-brand-logo { display: block; width: 32px; height: 32px; flex-shrink: 0; }
.rx-sidebar.rx-collapsed .rx-brand-logo { width: 28px; height: 28px; }

/* ---------------------------------------------------------------------------
   Documents (UPDATE_Documents §4)
--------------------------------------------------------------------------- */
.rx-doc-list { border-top: 1px solid var(--rx-border); }
.rx-doc-row {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--rx-border);
}
.rx-doc-row:last-child { border-bottom: 0; }
.rx-doc-row [data-doc-handle] { cursor: grab; }
.rx-doc-picker { max-height: 22rem; overflow: auto; }
.rx-doc-picker > li { border-bottom: 1px solid var(--rx-border); }
.rx-doc-picker > li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------------------
   Icons (UPDATE_Icons_Badges §1.5)

   Icon markup is inline SVG so it inherits the surrounding colour, which is
   the whole reason Tabler's outline set is used: one entry works on a light
   card and a dark one. Size comes from here, never from the file — the
   sanitizer drops the root's width and height for exactly this reason.
--------------------------------------------------------------------------- */
.pim-icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  color: inherit;
  vertical-align: middle;
}
.pim-icon-sm { width: 1.125rem; height: 1.125rem; }
.pim-icon-lg { width: 3rem; height: 3rem; }

.rx-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
}

/* The two swatches show the same icon against both surfaces at once, so a
   fixed colour is obvious before anybody assigns it to a spec. */
.rx-icon-swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--rx-border);
  border-radius: 0.5rem;
}
.rx-icon-swatch-light { background: #ffffff; color: #11181c; }
.rx-icon-swatch-dark  { background: #11181c; color: #f1f3f5; }

/* The tiles strip on the product's Specs tab: what the theme renders. */
.rx-tile-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.rx-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rx-border);
  border-radius: 0.5rem;
  min-width: 9rem;
}
.rx-tile-empty { border-style: dashed; }
.rx-tile-icon-missing {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border: 1px dashed var(--rx-border);
  border-radius: 0.25rem;
}

/* Badges (UPDATE_Icons_Badges.md §2.4). A pill shaped like the storefront's,
   so the preview reads as the product card and not as another table cell.
   Badge colours themselves are theme-wide (Theme settings › Colors › Product
   badges), so this is deliberately neutral rather than a guess at them. */
.rx-badge-pill {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--rx-border);
  border-radius: 999px;
  background: var(--rx-surface-subtle);
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: nowrap;
}
.rx-badge-pill-best { border-style: dashed; }
/* Past the storefront's limit: still assigned, simply not shown. */
.rx-badge-pill-cut {
  text-decoration: line-through;
  opacity: 0.6;
}
