/* ===================================== */
/* Layout Patterns */
/* ===================================== */
.workspace-col {
  width: 100%;
}

.tabs-container,
.workspace-shell {
  position: sticky;
  top: 0;
  max-height: calc(100vh - var(--workspace-top));
  overflow: hidden;
  border-color: var(--anx-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.tabs-container .card-header,
.tabs-container .card-body,
.workspace-shell .card-header,
.workspace-shell .card-body {
  overflow-wrap: anywhere;
}

.workspace-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - var(--workspace-top) - 96px);
  overflow: auto;
}

.main-form-col {
  min-width: 0;
}

.invoice-header-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--anx-space-2);
}

.toolbar-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.invoice-toolbar {
  gap: 0.5rem;
}

.invoice-toolbar .btn {
  white-space: nowrap;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.invoice-panel-body {
  min-height: 0;
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.invoice-form-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.95rem 0.95rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.invoice-info-grid,
#invoicePanel .row.g-3 {
  --bs-gutter-x: 0.85rem;
  --bs-gutter-y: 0.8rem;
}

.items-section-card .card-body {
  padding: 0.82rem !important;
}

.items-toolbar {
  gap: 0.55rem;
  margin-bottom: 0.58rem;
}

.items-toolbar .barcode-group {
  flex: 1 1 26rem;
  min-width: 200px;
}

.barcode-search-wrap {
  position: relative;
  flex: 1 1 26rem;
  min-width: 200px;
}

.totals-section,
.sticky-review-dock {
  position: sticky;
  bottom: 0;
  z-index: 8;
  flex-shrink: 0;
  padding: 0.15rem 0.95rem 0.95rem;
  background: linear-gradient(
    180deg,
    rgba(248, 250, 252, 0) 0%,
    rgba(248, 250, 252, 0.92) 16%,
    rgba(248, 250, 252, 0.98) 100%
  );
  backdrop-filter: blur(10px);
}

.summary-grid,
.reference-totals-grid {
  --bs-gutter-x: 0.72rem;
  --bs-gutter-y: 0.72rem;
}

/* ===================================== */
/* Utilities */
/* ===================================== */
.mono {
  font-family: var(--anx-font-family-mono);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0.01em;
}

.thin-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.thin-scroll::-webkit-scrollbar-thumb {
  background: rgba(140, 156, 173, 0.42);
  border-radius: 20px;
}

.thin-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(140, 156, 173, 0.58);
}

.thin-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.04);
}

.toast-wrap {
  position: fixed;
  inset-inline-start: 1rem;
  bottom: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.minw-lines {
  min-width: var(--lines-min-width);
}

.system-hidden,
.u-hidden {
  display: none !important;
}

.u-gap-2 {
  gap: var(--anx-space-2) !important;
}

.u-align-center {
  align-items: center !important;
}

.u-justify-between {
  justify-content: space-between !important;
}

.u-inline-center {
  display: inline-flex !important;
  align-items: center !important;
}

.u-minw-16rem {
  min-width: 16rem !important;
}

.cell-input:focus {
  outline: 0;
}

.row-flash td {
  animation: rowFlash 0.55s ease;
}

@keyframes rowFlash {
  0% {
    background-color: rgba(22, 135, 114, 0.16);
  }

  100% {
    background-color: inherit;
  }
}

body.column-resizing,
body.column-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

@media (min-width: 992px) {
  html[dir="rtl"] .invoice-layout-row {
    flex-direction: row-reverse;
  }

  html[dir="ltr"] .invoice-layout-row {
    flex-direction: row;
  }

  html[dir="rtl"] [data-layout-col="workspace"] {
    order: 2;
  }

  html[dir="rtl"] [data-layout-col="main"] {
    order: 1;
  }

  html[dir="ltr"] [data-layout-col="workspace"] {
    order: 1;
  }

  html[dir="ltr"] [data-layout-col="main"] {
    order: 2;
  }

  .workspace-col {
    width: var(--workspace-width);
    flex: 0 0 var(--workspace-width);
  }
}

@media (max-width: 1440px) and (min-width: 992px) {
  main.flex-grow-1 {
    padding: 0.85rem !important;
  }

  .card-header {
    padding: 0.86rem 0.95rem;
  }

  .card-body {
    padding: 0.95rem;
  }

  #invoicePanel > .invoice-panel-body {
    padding: 0 !important;
  }

  .invoice-form-scroll {
    padding: 0.88rem 0.88rem 0.5rem;
    gap: 0.82rem;
  }

  .items-toolbar .barcode-group,
  .barcode-search-wrap {
    flex-basis: 22rem;
  }
}

@media (max-width: 991.98px) {
  .invoice-layout-row {
    flex-direction: column;
  }

  .workspace-col,
  .main-form-col {
    width: 100%;
    flex: 0 0 100%;
  }

  .tabs-container,
  .workspace-shell {
    position: static;
    max-height: none;
  }

  .workspace-scroll {
    max-height: none;
  }

  .invoice-form-scroll {
    padding: 0.88rem 0.88rem 0.5rem;
    gap: 0.82rem;
  }

  .totals-section,
  .sticky-review-dock {
    padding: 0.12rem 0.88rem 0.88rem;
    background: linear-gradient(
      180deg,
      rgba(248, 250, 252, 0) 0%,
      rgba(248, 250, 252, 0.94) 20%,
      rgba(248, 250, 252, 0.99) 100%
    );
  }
}

@media (max-width: 767.98px) {
  .invoice-header-layout,
  .toolbar-layout,
  .invoice-toolbar {
    gap: 0.45rem;
  }

  .invoice-form-scroll {
    padding: 0.8rem 0.8rem 0.45rem;
  }

  .items-toolbar {
    margin-bottom: 0.5rem;
  }

  .items-toolbar .barcode-group,
  .barcode-search-wrap {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .summary-grid,
  .reference-totals-grid {
    --bs-gutter-x: 0.6rem;
    --bs-gutter-y: 0.6rem;
  }
}

/* ===================================== */
/* Modernization Overrides */
/* ===================================== */
main.flex-grow-1 {
  position: relative;
  isolation: isolate;
  padding: 1rem !important;
}

main.flex-grow-1::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 100% 0%, rgba(15, 118, 110, 0.09), transparent 24%),
    radial-gradient(circle at 0% 10%, rgba(15, 23, 42, 0.05), transparent 26%);
}

.workspace-col {
  padding-bottom: 0.2rem;
}

.tabs-container,
.workspace-shell {
  top: 0.2rem;
  max-height: calc(100vh - var(--workspace-top) + 0.2rem);
  border: var(--anx-border-glass);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84) 0%, rgba(248, 250, 252, 0.9) 100%);
  backdrop-filter: blur(20px) saturate(150%);
  box-shadow:
    0 20px 44px rgba(15, 23, 42, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.74) inset;
}

.workspace-scroll {
  max-height: calc(100vh - var(--workspace-top) - 102px);
}

.invoice-layout-row {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: 1rem;
}

.invoice-header-layout {
  gap: 0.8rem;
}

.toolbar-layout,
.invoice-toolbar {
  gap: 0.58rem;
}

.status-wrap {
  gap: 0.5rem;
}

.invoice-panel-body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34) 0%, rgba(248, 250, 252, 0.24) 100%);
}

.invoice-form-scroll {
  padding: 1.08rem 1.08rem 0.62rem;
  gap: 1rem;
}

.invoice-info-grid,
#invoicePanel .row.g-3 {
  --bs-gutter-x: 0.92rem;
  --bs-gutter-y: 0.86rem;
}

.items-section-card .card-body {
  padding: 0.92rem !important;
}

.items-toolbar {
  gap: 0.68rem;
  margin-bottom: 0.72rem;
}

.totals-section,
.sticky-review-dock {
  padding: 0.2rem 1.08rem 1.02rem;
  background:
    linear-gradient(180deg, rgba(243, 247, 251, 0) 0%, rgba(243, 247, 251, 0.72) 14%, rgba(243, 247, 251, 0.94) 100%);
  backdrop-filter: blur(14px);
}

.summary-grid,
.reference-totals-grid {
  --bs-gutter-x: 0.82rem;
  --bs-gutter-y: 0.82rem;
}

.toast-wrap {
  inset-inline-start: 1.1rem;
  bottom: 1.1rem;
}

.thin-scroll::-webkit-scrollbar-thumb {
  background: rgba(154, 167, 184, 0.46);
}

.thin-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(125, 141, 161, 0.62);
}

.thin-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.035);
}

@media (max-width: 1440px) and (min-width: 992px) {
  main.flex-grow-1 {
    padding: 0.9rem !important;
  }

  .invoice-form-scroll {
    padding: 1rem 1rem 0.56rem;
    gap: 0.9rem;
  }

  .totals-section,
  .sticky-review-dock {
    padding: 0.18rem 1rem 0.95rem;
  }
}

@media (max-width: 991.98px) {
  main.flex-grow-1 {
    padding: 0.88rem !important;
  }

  .tabs-container,
  .workspace-shell {
    top: 0;
    box-shadow: var(--anx-shadow-md);
  }

  .invoice-form-scroll {
    padding: 0.92rem 0.92rem 0.54rem;
    gap: 0.88rem;
  }

  .totals-section,
  .sticky-review-dock {
    padding: 0.16rem 0.92rem 0.92rem;
  }
}

@media (max-width: 767.98px) {
  main.flex-grow-1 {
    padding: 0.75rem !important;
  }

  .invoice-form-scroll {
    padding: 0.82rem 0.82rem 0.5rem;
    gap: 0.82rem;
  }

  .items-toolbar {
    margin-bottom: 0.58rem;
  }

  .totals-section,
  .sticky-review-dock {
    padding: 0.12rem 0.82rem 0.82rem;
  }
}

@media print {
  header,
  .workspace-col,
  #toastWrap,
  #validationArea {
    display: none !important;
  }

  body {
    background: #fff !important;
  }

  main {
    padding: 0 !important;
  }

  .container-fluid,
  .row,
  .main-form-col,
  .main-form-col > .card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .card,
  .card-header,
  .card-body {
    border: 0 !important;
    box-shadow: none !important;
  }

  .btn,
  .dropdown,
  .status-wrap {
    display: none !important;
  }
}
