/* =====================================================================
   Shared UI: data grids (search / sort / paging / fixed header & columns)
   and the "work in progress" overlay. Used by dct-ui.js.
   ===================================================================== */

/* ---------- grid toolbar & pager ---------- */
.dct-grid-toolbar,
.dct-grid-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    font-size: .8rem;
    color: var(--text-secondary, #6b7280);
    background: var(--surface-alt, #f9fafb);
}
.dct-grid-toolbar { border-bottom: 1px solid var(--border, #d1d5db); }
.dct-grid-pager   { border-top: 1px solid var(--border, #d1d5db); }
.dct-grid-toolbar .dct-grid-search { max-width: 280px; font-size: .8rem; }
.dct-grid-pager .form-select { width: auto; font-size: .8rem; padding-top: .15rem; padding-bottom: .15rem; }
.dct-grid-pager .pagination { margin: 0; }
.dct-grid-pager .page-link { font-size: .78rem; padding: .15rem .5rem; }
.dct-grid-info { margin-left: auto; }

/* ---------- scroll area with fixed header ---------- */
.dct-grid-scroll {
    overflow: auto;
    max-height: 65vh;
    position: relative;
}
/* collapsed borders do not move with sticky cells (scrolled text shows through the grid lines),
   so grid tables use separate borders: each cell draws only its right + bottom line */
.dct-grid-scroll > table { margin-bottom: 0; border-collapse: separate; border-spacing: 0; }
.dct-grid-scroll > table.table-bordered { border-width: 0; }
.dct-grid-scroll > table.table-bordered > :not(caption) > tr > * { border-width: 0 1px 1px 0; }
.dct-grid-scroll > table.table-bordered > :not(caption) > tr > :first-child { border-left-width: 1px; }
.dct-grid-scroll > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #eef2f7;
    box-shadow: inset 0 -1px 0 var(--border, #d1d5db);
}

/* fixed left columns (data-grid-sticky-cols="n") */
.dct-grid-scroll .dct-sticky {
    position: sticky;
    z-index: 2;
    background: var(--surface, #fff);
    box-shadow: inset -1px 0 0 var(--border, #d1d5db);
}
.dct-grid-scroll > table > thead > tr > th.dct-sticky { z-index: 4; background: #eef2f7; }
.dct-grid-scroll tr:hover > td.dct-sticky { background: #f5f8fc; }

/* ---------- sortable headers ---------- */
th.dct-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.dct-sortable::after { content: " \2195"; opacity: .35; font-size: .75em; }
th.dct-sortable[data-sort="asc"]::after  { content: " \25B2"; opacity: .8; }
th.dct-sortable[data-sort="desc"]::after { content: " \25BC"; opacity: .8; }
.dct-grid-empty td { text-align: center; color: var(--text-secondary, #6b7280); padding: 1rem; }

/* ---------- work-in-progress overlay ---------- */
#dct-busy {
    position: fixed;
    inset: 0;
    z-index: 1990;              /* above page content, Bootstrap modals and SweetAlert; it is always closed before a result popup opens */
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .45);
}
#dct-busy.show { display: flex; }
#dct-busy .dct-busy-box {
    background: #fff;
    border-radius: 10px;
    padding: 1.4rem 1.8rem;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
#dct-busy .dct-busy-title { font-weight: 600; margin-top: .75rem; color: #111827; }
#dct-busy .dct-busy-text  { font-size: .82rem; color: #6b7280; margin-top: .25rem; }
#dct-busy .dct-busy-time  { font-size: .75rem; color: #9ca3af; margin-top: .5rem; }

/* ---------- pending forms drill-down ---------- */
.dct-drill details { border-bottom: 1px solid var(--border, #e5e7eb); }
.dct-drill summary {
    cursor: pointer;
    list-style: none;
    padding: .45rem .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.dct-drill summary::-webkit-details-marker { display: none; }
.dct-drill summary::before { content: "\25B8"; font-size: .8em; color: #6b7280; transition: transform .15s; }
.dct-drill details[open] > summary::before { transform: rotate(90deg); }
.dct-drill .dct-drill-count { margin-left: auto; font-size: .75rem; }
.dct-drill details details summary { padding-left: 1.75rem; }
.dct-drill details details details summary { padding-left: 3rem; }
.dct-drill .dct-dates { padding: .4rem .75rem .6rem 3.5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.dct-drill .dct-date {
    font-size: .75rem;
    padding: .15rem .45rem;
    border-radius: 4px;
    background: #fdecec;
    color: #9b1c1c;
}
