/*
 * Management page patterns on top of the EcommerceBackend Sneat build (ADR 0020):
 * page header with breadcrumb, card tables, offcanvas forms, empty states, toasts and confirms.
 * Load order: ... -> shell.css -> pages.css. Tokens and Sneat/Bootstrap custom properties only.
 */

/* ---------- Page header (Views/Shared/_PageHeader, UI-STANDARD §3) ----------
 * One compact band (~56 px): module-coloured icon tile, title, info tooltip, breadcrumb pills, actions.
 * The module colour comes from the menu group (Shell/PageModules) as .igv-mod-{token}.
 */
.igv-page-header,
.igv-mod-primary { --igv-mod: var(--bs-primary); --igv-mod-rgb: var(--bs-primary-rgb); }
.igv-mod-success { --igv-mod: var(--bs-success); --igv-mod-rgb: var(--bs-success-rgb); }
.igv-mod-info { --igv-mod: var(--bs-info); --igv-mod-rgb: var(--bs-info-rgb); }
.igv-mod-warning { --igv-mod: var(--bs-warning); --igv-mod-rgb: var(--bs-warning-rgb); }
.igv-mod-secondary { --igv-mod: var(--bs-secondary); --igv-mod-rgb: var(--bs-secondary-rgb); }
.igv-mod-violet { --igv-mod: var(--app-violet); --igv-mod-rgb: var(--app-violet-rgb); }
.igv-mod-cyan { --igv-mod: var(--app-cyan); --igv-mod-rgb: var(--app-cyan-rgb); }
.igv-mod-pink { --igv-mod: var(--app-pink); --igv-mod-rgb: var(--app-pink-rgb); }

.igv-page-header {
  position: sticky;
  top: var(--app-space-2);
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-space-2) var(--app-space-3);
  min-height: 56px;
  margin-bottom: var(--app-space-4);
  padding: 0.5rem 1rem 0.5rem 0.875rem;
  border-left: 3px solid var(--igv-mod);
  border-radius: var(--app-radius-lg);
  background:
    linear-gradient(120deg, rgba(var(--igv-mod-rgb), 0.06) 0%, rgba(var(--igv-mod-rgb), 0) 55%),
    var(--bs-paper-bg);
  /* The first shadow paints the page background over the gap above the band, so rows never peek through. */
  box-shadow: 0 calc(-1 * var(--app-space-2)) 0 0 var(--bs-body-bg), var(--app-shadow);
  transition: min-height 0.2s ease, padding 0.2s ease;
}
.igv-page-header.is-stuck { min-height: 44px; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.igv-page-heading {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1 1 auto;
}
.igv-page-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--app-radius-lg);
  background: rgba(var(--igv-mod-rgb), 0.16);
  color: var(--igv-mod);
  transition: width 0.2s ease, height 0.2s ease;
}
.igv-page-icon .icon-base { font-size: 1.25rem; }
.is-stuck .igv-page-icon { width: 30px; height: 30px; }
.igv-page-title {
  margin: 0;
  overflow: hidden;
  color: var(--bs-heading-color);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.igv-page-info {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 0.125rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--bs-secondary-color);
  line-height: 1;
}
.igv-page-info:hover,
.igv-page-info:focus-visible { color: var(--igv-mod); }

.igv-crumbs { flex: 0 1 auto; min-width: 0; font-size: 0.8125rem; }
.igv-crumbs ol {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}
.igv-crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.igv-crumbs a,
.igv-crumbs span { color: var(--bs-secondary-color); }
.igv-crumbs a:hover { color: var(--igv-mod); }
.igv-crumb-home .icon-base { font-size: 1rem; }
.igv-crumb-sep { margin: 0 0.25rem; font-size: 1rem; color: var(--bs-secondary-color); opacity: 0.6; }
.igv-crumbs .igv-crumb-current {
  overflow: hidden;
  max-width: 16rem;
  padding: 0.125rem 0.625rem;
  border-radius: 50rem;
  background: rgba(var(--igv-mod-rgb), 0.16);
  /* Heading ink on the module tint: the module colour itself as text fell to 1.7-4.1:1 (M2b) */
  color: var(--bs-heading-color);
  font-weight: 500;
  text-overflow: ellipsis;
}
.igv-crumb-more { display: none !important; color: var(--bs-secondary-color); }

.igv-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-space-2);
}

/* Small screens: the trail drops to its own line and the middle crumbs fold into "…". */
@media (max-width: 991.98px) {
  .igv-page-heading { flex-basis: 100%; }
  .igv-crumbs { order: 3; flex-basis: 100%; }
  .igv-page-actions { order: 2; }
}
@media (max-width: 767.98px) {
  .igv-crumb-mid { display: none !important; }
  .igv-crumb-more { display: inline-flex !important; }
}
@media (max-width: 575.98px) {
  .igv-page-header { position: static; }
  .igv-page-actions { width: 100%; }
  .igv-page-actions > .btn,
  .igv-page-actions > form,
  .igv-page-actions > form > .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .igv-page-header,
  .igv-page-icon { transition: none; }
}
}

/* ---------- Messages: success becomes a toast once scripts run (assets/js/pages.js) ---------- */
.igv-js [data-igv-toast]:not(.is-shown) { display: none !important; }
.igv-flash .icon-base { font-size: 1.25rem; flex: 0 0 auto; }

/* ---------- Card tables ---------- */
.igv-card-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-space-3);
}
.igv-card-title { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.5; color: var(--bs-heading-color); }
.igv-count {
  display: inline-block;
  min-width: 1.5rem;
  margin-left: 0.375rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 50rem;
  background: rgba(var(--bs-secondary-rgb), 0.16);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.25rem;
  vertical-align: 0.0625rem;
}
.igv-search-box { position: relative; flex: 0 1 18rem; min-width: 0; }
.igv-search-box > .icon-base {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}
.igv-search-box .form-control { padding-left: 2.25rem; }
@media (max-width: 575.98px) {
  .igv-search-box { flex: 1 1 100%; }
}

/* Keeps absolutely positioned children (visually-hidden labels) inside the scroll box, so a wide table never widens the page. */
.table-responsive { position: relative; }
.igv-table { margin-bottom: 0; }
.igv-table > :not(caption) > * > * { vertical-align: middle; }
.igv-table thead th { white-space: nowrap; }
.igv-table td.bo-num,
.igv-table th.bo-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.igv-table .igv-col-actions { width: 1%; white-space: nowrap; text-align: right; }
.igv-cell-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.igv-cell-main > a,
.igv-cell-main > strong { color: var(--bs-heading-color); font-weight: 500; }
.igv-cell-main > a:hover { color: var(--bs-primary); }
.igv-cell-main > small { color: var(--bs-secondary-color); }
.igv-table tbody tr[data-igv-href] { cursor: pointer; }
.igv-table .igv-currency { margin-left: 0.25rem; color: var(--bs-secondary-color); font-size: 0.8125em; }
.igv-table tr.is-current > td:first-child { box-shadow: inset 3px 0 0 var(--bs-primary); }

/* Icon buttons in table rows: 32 px targets, visible focus. */
.igv-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  color: var(--bs-secondary-color);
}
.igv-row-btn:hover,
.igv-row-btn:focus-visible { background: rgba(var(--bs-primary-rgb), 0.12); color: var(--bs-primary); }
.igv-row-btn .icon-base { font-size: 1.25rem; }

.igv-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-space-2);
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}
.igv-card-footer .pagination { margin: 0; }

/* ---------- Empty states (Views/Shared/_EmptyState) ---------- */
.igv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--bs-secondary-color);
}
.igv-empty p { max-width: 42ch; }
.igv-empty h2 { color: var(--bs-heading-color); }
.igv-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 1rem;
  border-radius: 50%;
  background: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--bs-primary);
}
.igv-empty-icon .icon-base { font-size: 1.75rem; }
td > .igv-empty { padding-block: 2rem; }

/* ---------- Offcanvas forms ---------- */
.igv-offcanvas .offcanvas-body { display: flex; flex-direction: column; }
.igv-offcanvas form { display: flex; flex-direction: column; flex: 1 1 auto; }
.igv-offcanvas .igv-offcanvas-actions {
  display: flex;
  gap: var(--app-space-2);
  margin-top: auto;
  padding-top: var(--app-space-4);
}
.igv-offcanvas .igv-offcanvas-actions .btn { flex: 1 1 0; }
.igv-fact {
  display: flex;
  justify-content: space-between;
  gap: var(--app-space-3);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--app-radius);
  background: rgba(var(--bs-secondary-rgb), 0.08);
}
.igv-fact strong { color: var(--bs-heading-color); font-variant-numeric: tabular-nums; }

/* File drop zone (supplier PDF upload). */
.igv-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--app-radius-lg);
  text-align: center;
  color: var(--bs-secondary-color);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.igv-drop:hover,
.igv-drop.is-over,
.igv-drop:focus-within { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), 0.06); }
.igv-drop .icon-base { font-size: 2.5rem; color: var(--bs-primary); }
.igv-drop input[type="file"] { max-width: 100%; }

/* ---------- Detail pages ---------- */
.igv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}
.igv-meta .icon-base { margin-right: 0.25rem; vertical-align: -0.125rem; }
.igv-frame { display: block; width: 100%; height: 80vh; min-height: 28rem; border: 0; background: var(--app-paper); }
.igv-frame--paper { background: var(--bs-white); }
@media (min-width: 1400px) {
  .igv-sticky { position: sticky; top: 5.5rem; }
}
.igv-totals dt { font-weight: 400; }
.igv-totals dd { text-align: right; font-variant-numeric: tabular-nums; margin-bottom: 0.25rem; }

/* Service status list (purchasing settings). */
.igv-service { display: flex; gap: var(--app-space-3); align-items: flex-start; }
.igv-service .avatar { flex: 0 0 auto; }

/* ---------- Error and access pages ---------- */
.igv-misc { display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; text-align: center; }
.igv-misc-code { font-size: 4rem; font-weight: 700; line-height: 1; color: var(--bs-heading-color); }
.igv-misc img { max-width: min(100%, 18rem); height: auto; margin-top: 2rem; }

/* ---------- sweetalert2 in the Sneat theme, light and dark ----------
   sweetalert2 injects its own CSS after this file, so these selectors are one step more specific. */
html .swal2-container .swal2-popup {
  background: var(--bs-paper-bg);
  color: var(--bs-body-color);
  border-radius: var(--app-radius-lg);
  font-family: var(--app-font);
}
html .swal2-container .swal2-title { color: var(--bs-heading-color); font-size: 1.25rem; }
html .swal2-container .swal2-html-container { color: var(--bs-body-color); font-size: 0.9375rem; }
html .swal2-container .swal2-popup.swal2-toast { box-shadow: var(--app-shadow); border: 1px solid var(--bs-border-color); }
html .swal2-container .swal2-popup.swal2-toast .swal2-title { margin: 0.25rem 0.5rem; font-size: 0.9375rem; font-weight: 500; line-height: 1.4; }
html .swal2-container .swal2-actions { gap: var(--app-space-2); }
/* Toasts open below the detached navbar, not over the user menu. */
html .swal2-container.swal2-top-end { top: 4.75rem; }
.igv-barcodes { max-width: 14rem; }
.igv-qty-col { width: 7.5rem; }

/* Supplier invoice purchase preview (ADR 0026) */
.igv-invoice-lines .igv-invoice-cell { min-width: 14rem; }
.igv-invoice-lines .igv-product-col { min-width: 16rem; }
.igv-invoice-lines .igv-num-col { min-width: 6.5rem; }
.igv-invoice-lines tr.igv-line-skipped > td:not(:first-child) { opacity: .5; }
.igv-accept-note { min-width: min(18rem, 100%); }
.igv-empty-icon--warning { background: rgba(var(--bs-warning-rgb), 0.16); color: var(--bs-warning); }

/* Multi-line error text (failed events) */
.igv-pre-line { white-space: pre-line; }

.a13-notice { max-width: 72ch; overflow-wrap: anywhere; }
