/* my-gui table columns (MG4, part 1): resize handles, header drag, hidden columns, column chooser, filter row.
   Behaviour: js/table-columns.js. */

/* the whole head sticks (header, filter and summary rows together); the cells only anchor their handles */
.m-table.m-table--cols thead { position: sticky; top: 0; z-index: 2; }
.m-table.m-table--cols th { position: relative; top: auto; }
.m-table-scroll--tall { max-height: min(62vh, 520px); overscroll-behavior: contain; }
.m-table-scroll--tall::-webkit-scrollbar-corner { background: transparent; }

.m-table .m-col-off { display: none; }
.m-table.is-sized { table-layout: fixed; }
.m-table.is-sized th, .m-table.is-sized td { overflow: hidden; text-overflow: ellipsis; }
.m-table.m-table--cols th:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--m-ring); }

/* the double arrow between two columns */
.m-colrz {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 9px;
  cursor: col-resize;
  touch-action: none;
}
.m-colrz::after {
  content: "";
  position: absolute;
  inset-block: 9px;
  inset-inline-end: 0;
  width: 1px;
  background: var(--m-line);
  transition: width .15s;
}
.m-colrz:hover::after, .m-table th.is-resizing .m-colrz::after { inset-block: 4px; width: 3px; background: var(--m-accent); }
@media (pointer: coarse) {
  .m-colrz { width: 18px; }
  .m-colrz::after { inset-block: 7px; width: 2px; }
}

.m-col-resizing, .m-col-resizing * { cursor: col-resize !important; user-select: none; }
.m-col-dragging, .m-col-dragging * { cursor: grabbing !important; user-select: none; }
.m-table th.is-drag { opacity: .45; }
.m-table th.m-drop-before { box-shadow: inset 3px 0 0 var(--m-accent); }
.m-table th.m-drop-after { box-shadow: inset -3px 0 0 var(--m-accent); }
[dir="rtl"] .m-table th.m-drop-before { box-shadow: inset -3px 0 0 var(--m-accent); }
[dir="rtl"] .m-table th.m-drop-after { box-shadow: inset 3px 0 0 var(--m-accent); }

/* view panel: a popover by its button, a bottom sheet on a narrow screen (js places it) */
.m-colpanel {
  position: fixed; z-index: 90; display: flex; flex-direction: column; gap: 10px; box-sizing: border-box;
  width: min(340px, calc(100vw - 16px)); overflow: auto; overscroll-behavior: contain; padding: 12px;
  border: 1px solid var(--m-line-strong); border-radius: var(--m-r); background: var(--m-modal); color: var(--m-text);
  box-shadow: 0 24px 60px -16px rgba(var(--m-shade), calc(.9 * var(--m-sk)));
  animation: m-rise .22s var(--m-ease) both;
}
.m-colpanel > * { flex: 0 0 auto; }
.m-colpanel[hidden] { display: none; }
.m-colpanel:focus { outline: none; }
.m-colpanel.is-sheet {
  inset: auto 0 0 0; width: auto; max-height: 82vh; max-height: 82dvh; padding-block-end: calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  box-shadow: 0 0 0 100vmax var(--m-scrim), 0 -18px 50px -16px rgba(var(--m-shade), calc(.9 * var(--m-sk)));
}
.m-colpanel-head { position: sticky; top: -12px; z-index: 3; display: flex; align-items: center; gap: 4px; margin: -12px -12px 0; padding: 12px 12px 6px; background: var(--m-modal); }
.m-colpanel-title { flex: 1 1 0%; font-size: 14px; font-weight: 800; }
.m-colpanel-hint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--m-text-3); }
.m-colpanel-hint[hidden] { display: none; }
.m-colpanel-search { width: 100%; box-sizing: border-box; }
.m-colpanel-row { display: flex; gap: 6px; }
.m-colpanel-list { gap: 3px; }
.m-colpanel-item.m-reorder-item { gap: 6px; min-width: 0; min-height: 30px; padding-block: 0; }
.m-colpanel-item .m-reorder-handle { height: 28px; }
.m-colpanel-item[hidden] { display: none; }
.m-colpanel-name { display: flex; flex: 1 1 0%; align-items: center; gap: 8px; min-width: 0; min-height: 28px; font-size: 12.5px; color: var(--m-text-2); cursor: pointer; }
.m-colpanel-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-colpanel-opts { display: flex; flex-direction: column; padding-block-start: 8px; border-block-start: 1px solid var(--m-line); }
.m-colpanel-opts .m-colpanel-name { flex: 0 0 auto; }
@media (pointer: coarse) { .m-colpanel-item .m-reorder-handle { width: 36px; height: 40px; } .m-colpanel-opts .m-colpanel-name { min-height: 40px; } }

/* active column filters */
.m-filterchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 14px; border-block-end: 1px solid var(--m-line); }
.m-filterchips[hidden] { display: none; }
.m-filterchip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding-inline: 10px 8px; border: 0; border-radius: 99px; background: var(--m-accent-wash); color: var(--m-text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.m-filterchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-filterchip .m-i { width: 12px; height: 12px; opacity: .7; }
.m-filterchip:hover .m-i { opacity: 1; }
.m-filterchip:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--m-ring); }
@media (pointer: coarse) { .m-filterchip { height: 36px; } }

/* pinned first column (with the selection column before it) */
.m-table.is-pinned th.m-col-sel, .m-table.is-pinned td.m-col-sel { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--m-card-solid); }
.m-table.is-pinned th.m-col-first, .m-table.is-pinned td.m-col-first { position: sticky; inset-inline-start: var(--m-pin, 0px); z-index: 1; background: var(--m-card-solid); border-inline-end: 1px solid var(--m-line); }
.m-table.is-pinned thead th.m-col-first, .m-table.is-pinned thead th.m-col-sel { z-index: 3; }
.m-table.is-pinned tbody tr:not(.m-empty-row):hover td.m-col-first, .m-table.is-pinned tbody tr:not(.m-empty-row):hover td.m-col-sel { background: linear-gradient(rgba(var(--m-ink), .035), rgba(var(--m-ink), .035)), var(--m-card-solid); }
.m-table.is-pinned tbody tr.is-sel td.m-col-first, .m-table.is-pinned tbody tr.is-sel td.m-col-sel { background: linear-gradient(var(--m-accent-wash), var(--m-accent-wash)), var(--m-card-solid); }

/* found words (CSS Highlight API) */
::highlight(m-find) { background-color: rgba(255, 190, 0, .38); }

.m-table thead .m-filter-row td { height: auto; padding: 4px 6px 6px; background: var(--m-card-solid); border-block-end: 1px solid var(--m-line); }
.m-table .m-filter-row[hidden] { display: none; }
.m-colfilter { width: 100%; min-width: 76px; height: 30px; font-size: 12px; }
.m-table.is-sized .m-colfilter { min-width: 0; }
/* a list filter as a combo box (js/combo.js) */
.m-filter-row .m-combo { min-width: 118px; font-weight: 400; text-transform: none; letter-spacing: normal; text-align: start; }
.m-filter-row .m-combo > .m-input { height: 30px; font-size: 12px; }
.m-table.is-sized .m-filter-row .m-combo { min-width: 0; }
