/*
 * GridView styles - extracted verbatim from the <style> block that lived inside
 * Shared/Partials/GridView/GridView.razor.
 *
 * WHY GLOBAL AND NOT GridView.razor.css
 * This looks like component CSS but it is not. Several of its selectors target markup that
 * GridView does NOT render:
 *
 *   .gb-grid-fit / .gb-grid-fit-fixed  - the CONSUMER wraps the grid in these
 *                                        (Inventories/*.razor and others)
 *   td, th, td.sticky-tableData        - supplied by the consumer through
 *                                        RowTemplate / TableHeder1 (sticky-tableData alone
 *                                        appears in 580 files)
 *
 * CSS isolation stamps its b-XXXXXXXXXX scope attribute only onto elements the component
 * itself renders, and ::deep only reaches DESCENDANTS of those. A .gb-grid-fit wrapper lives
 * in a different component entirely, so no amount of ::deep can reach it - moving these rules
 * into GridView.razor.css would silently strip styling from every one of those pages.
 *
 * Keeping them global also fixes a second problem: as an inline <style> this block was emitted
 * once PER GridView INSTANCE, duplicating ~150 lines of CSS in the DOM on any page with more
 * than one grid.
 *
 * Linked from Pages/_Master.cshtml AFTER override.css, to preserve the late-in-cascade position
 * the inline <style> had (an inline style block in <body> wins ties against <head> links).
 *
 * Selectors are unchanged from the original, so rendering is identical.
 */

    .gb-gridview {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .gb-grid-scroll-tools {
        display: none;
        align-items: center;
        gap: .75rem;
        width: 100%;
        margin: 1rem 0 .5rem;
    }

    .gb-gridview.gb-grid-has-horizontal-overflow .gb-grid-scroll-tools {
        display: flex;
    }

    .gb-grid-scroll-button {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border: 1px solid #e4e6ef;
        border-radius: .475rem;
        background: #f5f8fa;
        color: var(--kt-primary);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    }

        .gb-grid-scroll-button:hover,
        .gb-grid-scroll-button:focus {
            background: var(--kt-primary);
            border-color: var(--kt-primary);
            color: #fff;
        }

    .gb-grid-top-scroll {
        flex: 1 1 auto;
        min-width: 0;
        height: 18px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: auto;
        scrollbar-color: var(--kt-primary) #eef3f7;
    }

    .gb-grid-top-scroll-spacer {
        height: 1px;
    }

    .gb-grid-table-scroll {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        padding-bottom: .85rem;
        scrollbar-width: auto;
        scrollbar-color: var(--kt-primary) #eef3f7;
    }

    .gb-grid-table {
        width: max-content;
        min-width: 100%;
    }

        .gb-grid-table th,
        .gb-grid-table td,
        .gb-grid-table td p {
            white-space: nowrap;
        }

    .gb-grid-fit .gb-grid-table {
        width: 100%;
        min-width: 0;
    }

    .gb-grid-fit .gb-grid-table th,
    .gb-grid-fit .gb-grid-table td,
    .gb-grid-fit .gb-grid-table td p {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .gb-grid-fit .gb-grid-table td p {
        margin-bottom: 0;
    }

    .gb-grid-fit .gb-grid-table th.sticky-tableData,
    .gb-grid-fit .gb-grid-table td.sticky-tableData {
        white-space: nowrap;
    }

    .gb-grid-fit .gb-grid-table th.gb-col-check,
    .gb-grid-fit .gb-grid-table td.gb-col-check {
        width: 40px;
        min-width: 0 !important;
    }

    .gb-grid-fit .gb-grid-table th.gb-col-idx,
    .gb-grid-fit .gb-grid-table td.gb-col-idx {
        width: 50px;
        min-width: 0 !important;
    }

    .gb-grid-fit-fixed .gb-grid-table {
        table-layout: fixed;
    }

    .gb-grid-top-scroll::-webkit-scrollbar,
    .gb-grid-table-scroll::-webkit-scrollbar {
        height: 16px;
    }

    .gb-grid-top-scroll::-webkit-scrollbar-track,
    .gb-grid-table-scroll::-webkit-scrollbar-track {
        background: #eef3f7;
        border-radius: 999px;
    }

    .gb-grid-top-scroll::-webkit-scrollbar-thumb,
    .gb-grid-table-scroll::-webkit-scrollbar-thumb {
        background: var(--kt-primary);
        border: 3px solid #eef3f7;
        border-radius: 999px;
    }

        .gb-grid-top-scroll::-webkit-scrollbar-thumb:hover,
        .gb-grid-table-scroll::-webkit-scrollbar-thumb:hover {
            background: var(--kt-primary-active);
        }

    @media (max-width: 767.98px) {
        .gb-grid-scroll-tools {
            gap: .5rem;
        }

        .gb-grid-scroll-button {
            width: 34px;
            height: 34px;
            flex-basis: 34px;
        }
    }

/* GridView pager: wraps instead of overflowing; trims to prev / nearby pages / next on phones. */
.gb-grid-pager {
    max-width: 100%;
    overflow-x: hidden;
}

    .gb-grid-pager .pagination {
        row-gap: .25rem;
    }

    .gb-grid-pager .gb-grid-pager-input {
        width: 80px;
    }

@media (max-width: 767.98px) {
    .gb-grid-pager .page-item.m-1 {
        margin: .125rem !important;
    }

    .gb-grid-pager .gb-grid-pager-info {
        flex-basis: 100%;
        justify-content: center;
        display: flex;
    }
}

@media (max-width: 575.98px) {
    .gb-grid-pager .gb-grid-pager-jump,
    .gb-grid-pager .gb-grid-pager-far {
        display: none;
    }

    .gb-grid-pager .gb-grid-pager-input {
        width: 64px;
    }
}

/* Prev/next chevrons are authored for RTL (previous = chevron-right); mirror them in LTR. */
[dir="ltr"] .gb-grid-pager .fa-chevron-left,
[dir="ltr"] .gb-grid-pager .fa-chevron-right {
    transform: scaleX(-1);
}

/* ---------------------------------------------------------------------------
   Phone card layout (< 768px)
   The desktop table kept its full width on phones: the sticky actions column and the
   min-w-150px data columns left only the checkbox and the actions visible, with the data
   hidden behind a sideways scroll. On phones each row becomes a card and each cell shows
   its column header (data-label, set by grid-view-scroll.js) next to its value.
   Selectors repeat .gb-grid-table to outrank the generated skin's .gm-grid cell rules.
   --------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .gb-gridview .gb-grid-scroll-tools {
        display: none !important;
    }

    .gb-gridview .gb-grid-table-scroll {
        overflow-x: visible !important;
    }

    .gb-gridview .gb-grid-table.gb-grid-table,
    .gb-gridview .gb-grid-table.gb-grid-table > tbody {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }

    .gb-gridview .gb-grid-table.gb-grid-table > thead {
        display: none;
    }

    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr {
        display: block;
        margin: 0 0 .75rem;
        padding: .5rem .85rem;
        border: 1px solid var(--kt-border-color, #e4e6ef);
        border-radius: 12px;
        background: var(--kt-card-bg, #fff);
    }

    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: .45rem 0 !important;
        border: 0 !important;
        border-bottom: 1px dashed var(--kt-border-color, #eff2f5) !important;
        text-align: end !important;
        white-space: normal !important;
        word-break: break-word;
        position: static !important;
        box-shadow: none !important;
    }

    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td:last-child {
        border-bottom: 0 !important;
    }

    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        flex: 0 0 40%;
        max-width: 40%;
        text-align: start;
        font-weight: 600;
        color: var(--kt-text-muted);
    }

    /* Cell content: drop the desktop centring/margins so the value sits opposite its label. */
    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td > p {
        margin: 0 !important;
        text-align: end !important;
    }

    /* Actions: wrap the buttons instead of stretching the card. */
    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td.sticky-tableData > *,
    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td .gm-ops {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: .4rem;
    }

    /* Loading / empty / full-width rows keep a single centred cell. */
    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr > td[colspan] {
        display: block;
        text-align: center !important;
        border-bottom: 0 !important;
    }

    .gb-gridview .gb-grid-table.gb-grid-table > tbody > tr:has(> td[colspan]) {
        border: 0;
        padding: 0;
    }
}
