/*
 * Accounting workspace helpers (fullscreen / recipe overflow) + minimal More alignment.
 * More *behavior* (max 6) lives in accounting-tab-more.js.
 * More *skin* comes from mtn-ui-kit style.css (.cicosy-tab-overflow*).
 * Do not re-skin the menu here; do not clip the tab shell (that hides the dropdown).
 */

/* --- Minimal More alignment (kit menu CSS remains authoritative) --- */

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"],
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.cicosy-invoice-tabs-shell:has([data-cicosy-accounting-tabs-ready="true"]),
.cicosy-ledger-tabs-shell:has([data-cicosy-accounting-tabs-ready="true"]),
.accounting-compliance-tabs-shell:has([data-cicosy-accounting-tabs-ready="true"]) {
  display: flex;
  align-items: stretch;
  min-height: 34px;
  height: 34px;
  /* visible so the More dropdown is not clipped */
  overflow: visible;
  max-width: 100%;
}

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-invoice-tab,
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-ledger-tab,
.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow.is-cicosy-more-visible,
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow.is-cicosy-more-visible {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  height: 100%;
  box-sizing: border-box;
}

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow,
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow {
  position: relative;
  flex: 0 0 auto;
  align-self: stretch;
  height: 100%;
  z-index: 20;
}

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow[hidden],
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow[hidden],
.cicosy-tab-overflow[hidden] {
  display: none !important;
}

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow.is-cicosy-more-visible:not([hidden]),
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] > .cicosy-tab-overflow.is-cicosy-more-visible:not([hidden]) {
  display: inline-flex !important;
}

.cicosy-invoice-tabs[data-cicosy-accounting-tabs-ready="true"] .cicosy-tab-overflow-toggle,
.cicosy-ledger-tabs[data-cicosy-accounting-tabs-ready="true"] .cicosy-tab-overflow-toggle {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  height: 100%;
  margin: 0;
  padding-block: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  gap: 0.35rem;
  cursor: pointer;
}

/* Overflowed tabs stay in the DOM; kit already defines .cicosy-tab-is-overflowed */

/* Report / AR stacks: allow kit More menus to paint outside the strip. */
.cicosy-report-library-recipe,
.cicosy-report-library-recipe .cicosy-invoice-page,
.cicosy-receivable-invoice-recipe .cicosy-invoice-page,
.cicosy-payable-invoice-recipe .cicosy-invoice-page,
.accounting-compliance-page-shell,
.cicosy-invoice-recipe.accounting-compliance-page-shell {
  overflow: visible;
}

.cicosy-report-library-recipe .cicosy-invoice-page > section,
.cicosy-receivable-invoice-recipe .cicosy-invoice-page > section,
.cicosy-payable-invoice-recipe .cicosy-invoice-page > section {
  position: relative;
  z-index: 1;
}

.cicosy-report-library-recipe .cicosy-invoice-page > section:has(.cicosy-tab-overflow.is-open),
.cicosy-receivable-invoice-recipe .cicosy-invoice-page > section:has(.cicosy-tab-overflow.is-open),
.cicosy-payable-invoice-recipe .cicosy-invoice-page > section:has(.cicosy-tab-overflow.is-open) {
  z-index: 30;
}

/* AR invoice list: keep table-shell overflow-x scrolling; menus portal to body. */
.cicosy-receivable-invoice-recipe .cicosy-invoice-c-actions {
  min-width: 8.5rem;
  width: auto;
  overflow: visible;
}

/* Invoice / cashbook Full Screen: fill the viewport and fit line tables (no inner scroll). */
.is-workspace-fullscreen,
:fullscreen {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--color-surface, #fff);
  padding: var(--spacing-md, 1rem);
}

.is-workspace-fullscreen > *:not(.ui-autocomplete):not(dialog):not(.cicosy-invoice-context-menu),
:fullscreen > *:not(.ui-autocomplete):not(dialog):not(.cicosy-invoice-context-menu) {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.is-workspace-fullscreen > .ui-autocomplete,
:fullscreen > .ui-autocomplete {
  width: auto;
  max-width: min(24rem, 100%);
  z-index: 4000;
}

.is-workspace-fullscreen > .cicosy-invoice-context-menu,
:fullscreen > .cicosy-invoice-context-menu {
  width: auto;
  max-width: min(16rem, 100%);
}

.is-workspace-fullscreen article,
.is-workspace-fullscreen .cicosy-form-layout-sectioned,
:fullscreen article,
:fullscreen .cicosy-form-layout-sectioned {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  max-height: none;
}

.is-workspace-fullscreen .cicosy-data-table,
.is-workspace-fullscreen .cicosy-invoice-table-shell,
:fullscreen .cicosy-data-table,
:fullscreen .cicosy-invoice-table-shell {
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  max-height: none !important;
}

.is-workspace-fullscreen .cicosy-invoice-table-shell table,
.is-workspace-fullscreen table.cicosy-table,
.is-workspace-fullscreen table.ar-invoice-lines,
.is-workspace-fullscreen table.ar-credit-lines,
.is-workspace-fullscreen table.ap-invoice-lines,
.is-workspace-fullscreen table.ap-grv-lines,
.is-workspace-fullscreen table.ap-credit-lines,
.is-workspace-fullscreen table.ap-debit-lines,
.is-workspace-fullscreen table.quote-lines,
.is-workspace-fullscreen table.ar-customer-journal-lines,
.is-workspace-fullscreen table.ap-supplier-journal-lines,
.is-workspace-fullscreen table.ar-recurring-lines,
.is-workspace-fullscreen table.je-journal-lines,
:fullscreen .cicosy-invoice-table-shell table,
:fullscreen table.cicosy-table,
:fullscreen table.ar-invoice-lines,
:fullscreen table.ar-credit-lines,
:fullscreen table.ap-invoice-lines,
:fullscreen table.ap-grv-lines,
:fullscreen table.ap-credit-lines,
:fullscreen table.ap-debit-lines,
:fullscreen table.quote-lines,
:fullscreen table.ar-customer-journal-lines,
:fullscreen table.ap-supplier-journal-lines,
:fullscreen table.ar-recurring-lines,
:fullscreen table.je-journal-lines {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  table-layout: fixed;
}

.is-workspace-fullscreen .cicosy-invoice-table-shell th,
.is-workspace-fullscreen .cicosy-invoice-table-shell td,
:fullscreen .cicosy-invoice-table-shell th,
:fullscreen .cicosy-invoice-table-shell td {
  min-width: 0 !important;
  max-width: none;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}

.is-workspace-fullscreen .cicosy-invoice-table-shell .form-control,
.is-workspace-fullscreen .cicosy-invoice-table-shell .form-select,
.is-workspace-fullscreen .cicosy-invoice-table-shell .cicosy-form-control,
.is-workspace-fullscreen .cicosy-invoice-table-shell .cicosy-form-select,
:fullscreen .cicosy-invoice-table-shell .form-control,
:fullscreen .cicosy-invoice-table-shell .form-select,
:fullscreen .cicosy-invoice-table-shell .cicosy-form-control,
:fullscreen .cicosy-invoice-table-shell .cicosy-form-select {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

.is-workspace-fullscreen .cicosy-invoice-table-shell .d-flex,
:fullscreen .cicosy-invoice-table-shell .d-flex {
  flex-wrap: wrap !important;
  min-width: 0;
  max-width: 100%;
}

.is-workspace-fullscreen .cicosy-invoice-table-shell .cicosy-btn,
:fullscreen .cicosy-invoice-table-shell .cicosy-btn {
  flex: 1 1 auto;
  min-width: 0;
}
