/* ListView three-zone layout — matches legacy UIComponents ListViewBaseComponent.razor.css */

.listview-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.listview-container.listview-fill-container {
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

.listview-chrome-top {
    flex-shrink: 0;
}

.listview-table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
}

.listview-table-scroll--loading .listview-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 6rem;
    background-color: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.82);
}

.listview-table-scroll--loading:not(:has(table)) .listview-loading-overlay {
    position: static;
    min-height: 8rem;
}

.listview-loading-text {
    font-size: 0.9rem;
}

.listview-container:not(.listview-fill-container) .listview-table-scroll {
    max-height: var(--listview-table-max-height, min(60dvh, 32rem));
}

.listview-chrome-bottom {
    flex-shrink: 0;
    flex-wrap: nowrap;
    border-top: 1px solid #000;
    padding-top: 0.5rem;
    padding-bottom: 0;
    min-width: 0;
}

.listview-page-size-select {
    width: auto;
    max-width: 7.5rem;
    flex: 0 0 auto;
}

.listview-total-rows {
    min-width: 0;
    font-size: 0.875rem;
}

.listview-pager-btn {
    flex: 0 0 auto;
}

.listview-pager-icon {
    display: none;
}

@media (max-width: 991.98px) {
    .listview-container > .listview-chrome-bottom {
        padding-top: 0.35rem;
        padding-bottom: 0.25rem;
        gap: 0.35rem;
    }

    .listview-search-filter-row.mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .listview-pager-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .listview-pager-icon {
        display: inline-block;
    }

    .listview-pager-btn {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
        line-height: 1;
    }

    .listview-container > .listview-chrome-bottom > .listview-pager {
        margin-left: 0 !important;
    }

    .of-crud-list-nested-panel .listview-search-filter-row > .ms-auto {
        margin-left: 0 !important;
    }

    section.of-crud-list-surface > .listview-page-host > .listview-chrome-top > .listview-search-filter-row > .listview-search-slot {
        anchor-name: --clubivate-list-search;
    }

    .of-crud-list-nested-panel .listview-search-slot {
        anchor-name: none;
    }

    .of-crud-list-nested-panel .listview-search-filter-row {
        position: sticky;
        left: 0;
        width: max-content;
        max-width: 100%;
        background-color: var(--bs-light);
    }

    .of-crud-list-nested-panel .listview-search-slot {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        width: anchor-size(--clubivate-list-search width, 12rem) !important;
        max-width: anchor-size(--clubivate-list-search width, 12rem) !important;
    }

    .of-crud-list-nested-panel .listview-search-slot .debounced-search-input-group,
    .of-crud-list-nested-panel .listview-search-slot .listview-search-input-wrap {
        min-width: 0 !important;
        max-width: 100%;
        width: 100%;
    }

    .listview-table-scroll > table > :not(caption) > * > * {
        padding: 0.3rem 0.4rem;
    }
}

/* Sticky header applies only to the scrollport's direct table — not nested ListSurfaceSelection tables. */
.listview-table-scroll > table > thead > tr > th {
    position: sticky;
    top: 0;
    background-color: var(--bs-body-bg, #fff);
    box-shadow: inset 0 -1px 0 #000;
}

/* Nested offer list: inset box-shadow is clipped on the last header cell (Åtgärder) inside the expanded row. Paint the rule in the cell background so it spans every column. */
.of-crud-list-nested-panel .listview-table-scroll > table > thead > tr > th {
    box-shadow: none;
    background-color: var(--bs-body-bg, #fff);
    background-image: linear-gradient(#000, #000);
    background-repeat: no-repeat;
    background-position: left bottom;
    background-size: 100% 1px;
}

/* Nested ListSurfaceSelection: sticky header scrolls inside .table-responsive only. */
.of-list-surface-selection-table-scroll > table > thead > tr > th {
    position: sticky;
    top: 0;
    background-color: var(--bs-body-bg, #fff);
    box-shadow: inset 0 -1px 0 #dee2e6;
}

.ui-stack-layer--viewport-host.list-filtrera-viewport-host {
    align-items: flex-start;
    justify-content: flex-start;
}

.ui-stack-layer--viewport-host.list-filtrera-viewport-host .list-filtrera-panel {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    bottom: max(0.5rem, env(safe-area-inset-bottom));
    left: 0.5rem;
    display: flex;
    flex-direction: column;
    width: auto;
    max-width: calc(100vw - 1rem);
    min-width: 0;
    min-height: 0;
    max-height: none;
    height: auto;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: auto;
    padding: 0.75rem;
    background-color: #fff;
    border: 1px solid #adb5bd;
    border-radius: 0.375rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12);
}

.list-filtrera-panel .list-filtrera-tabs {
    flex: 0 0 auto;
    align-self: stretch;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.list-filtrera-panel .list-filtrera-tabs > .nav-tabs {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    margin-bottom: 0;
}

.list-filtrera-panel .list-filtrera-tabs .nav-item {
    flex: 0 0 auto;
}

.list-filtrera-panel .list-filtrera-tabs .nav-link {
    white-space: nowrap;
}

.list-filtrera-panel .list-filtrera-tree {
    --tree-indent: 24px;
    --tree-line-color: #6c757d;
    --tree-line-width: 2px;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.list-filtrera-panel .list-filtrera-tree .location-tree-node {
    position: relative;
    padding-left: var(--tree-indent);
}

.list-filtrera-panel .list-filtrera-tree > .location-tree-node {
    padding-left: 0;
}

.list-filtrera-panel .list-filtrera-tree .location-tree-lines {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--tree-indent);
    height: auto;
    pointer-events: none;
}

.list-filtrera-panel .list-filtrera-tree .location-line-vertical {
    position: absolute;
    left: calc(var(--tree-indent) / 2 - 1px);
    top: 0;
    bottom: 0;
    width: var(--tree-line-width);
    height: auto;
    background-color: var(--tree-line-color);
}

.list-filtrera-panel .list-filtrera-tree .location-tree-node.is-last-child > .location-tree-lines > .location-line-vertical {
    bottom: auto;
    height: 14px;
}

.list-filtrera-panel .list-filtrera-tree .location-line-horizontal {
    position: absolute;
    left: calc(var(--tree-indent) / 2 - 1px);
    top: 14px;
    width: calc(var(--tree-indent) / 2);
    height: var(--tree-line-width);
    background-color: var(--tree-line-color);
}

.list-filtrera-panel .list-filtrera-actions {
    flex: 0 0 auto;
}

.list-filtrera-panel--inline {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 18rem;
    max-height: min(32rem, calc(100vh - 18rem));
    overflow: hidden;
    padding: 0.75rem;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.listview-search-filter-row .listview-search-slot {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 20rem;
}

.listview-search-filter-row .listview-search-group,
.listview-search-filter-row .listview-search-group .debounced-search-input-group,
.listview-search-filter-row .listview-search-group.debounced-search-container .debounced-search-input-group {
    max-width: none;
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
}

.listview-search-filter-row .form-control {
    min-width: 0;
}

.listview-search-group .listview-search-label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.listview-search-group .listview-search-input-wrap,
.of-list-surface-selection .listview-search-input-wrap {
    max-width: 320px;
    flex: 0 1 320px;
    min-width: 12rem;
}

.listview-search-group.debounced-search-container .debounced-search-input-group {
    max-width: 320px;
    flex: 0 1 320px;
    min-width: 12rem;
}

.listview-search-group .debounced-search-input-group {
    box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
    border-radius: 0.5rem;
}

.listview-filters-panel .listview-filter-dropdown .dropdown-toggle.active-filter {
    border-color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.listview-container .actions-cell {
    white-space: nowrap;
    width: 1%;
}

.listview-container button.lv-action-btn {
    white-space: nowrap;
}

.listview-filters-panel .dropdown-menu:not(.show) {
    display: none;
}

/* Modal-hosted fill ListView: list body scrolls; modal-body does not double-scroll. */
.clubivate-modal-dialog-host .modal-body:has(.listview-fill-container),
.modal.fade.show.d-block .modal-body:has(.listview-fill-container) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.clubivate-modal-dialog-host .modal-body .listview-page-host.listview-fill-container,
.modal.fade.show.d-block .modal-body .listview-page-host.listview-fill-container,
.clubivate-modal-dialog-host .modal-body .listview-fill-container,
.modal.fade.show.d-block .modal-body .listview-fill-container {
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

/* ManualTests / wide-column overflow harness — horizontal scroll stays in .listview-table-scroll. */
.listview-fill-test-wide-cells th,
.listview-fill-test-wide-cells td {
    min-width: 10rem;
    white-space: nowrap;
}

/* ManualTests modal scenario — cap list height so V overflow is provable at 1920×1080. */
.listview-info-col {
    width: 2.75rem;
    min-width: 2.75rem;
    max-width: 2.75rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    text-align: center;
    vertical-align: middle;
}

.listview-fill-modal-host {
    max-height: min(52vh, calc(var(--clubivate-modal-viewport-height, 80vh) - 9rem));
}

/* Row action menu (RowActionsDropdown), in the row and on the UI stack. position-area places it in the
   page area beside the button: from its left edge, mirrored to its right edge when there is no room.
   It opens below or above, whichever side has more room. max-height: stretch stops it at the page edge
   (the margins keep it off the top menu and the footer), so a longer menu scrolls.
   Every option keeps max-height: Chrome does not apply an option after one that overflows. */
.row-actions-dropdown > .dropdown-menu.row-actions-dropdown-menu,
.row-actions-viewport-host .row-actions-stack-menu {
    position: fixed;
    inset: auto;
    margin: 0.125rem 0 calc(var(--clubivate-footer-height, 0px) + 0.25rem);
    position-area: bottom span-right;
    max-height: stretch;
    overflow-y: auto;
    position-try-fallbacks: flip-inline, --row-actions-up, --row-actions-up flip-inline;
    position-try-order: most-block-size;
}

@position-try --row-actions-up {
    position-area: top span-right;
    margin: calc(var(--clubivate-topmenu-height, 0px) + 0.25rem) 0 0.125rem;
}

.workplan-filter-menu > .dropdown-menu {
    max-height: calc(100dvh - var(--clubivate-topmenu-height, 0px) - var(--clubivate-footer-height, 0px) - 1rem);
}
