/* my-gui table tools (MG4): header menu button, next sort keys, date range filter, panel actions, bottom
   selection bar, row details, saved views. Behaviour: js/table*.js. */

/* ---------- header menu ---------- */
.m-table.m-table--menu th:not(.m-col-sel) { padding-inline-end: 30px; }
.m-colmenu-btn { position: absolute; inset-inline-end: 9px; top: 50%; display: grid; place-items: center; width: 20px; height: 22px; padding: 0; border: 0; border-radius: var(--m-r-sm); background: transparent; color: var(--m-text-3); cursor: pointer; opacity: 0; transform: translateY(-50%); transition: opacity .15s; }
.m-colmenu-btn .m-i { width: 14px; height: 14px; }
.m-table th:hover .m-colmenu-btn, .m-table th:focus-visible .m-colmenu-btn, .m-colmenu-btn:focus-visible { opacity: 1; }
.m-colmenu-btn:hover { color: var(--m-text); background: rgba(var(--m-ink), .08); }
@media (hover: none) { .m-colmenu-btn { opacity: .75; } }
@media (pointer: coarse) { .m-table.m-table--menu th:not(.m-col-sel) { padding-inline-end: 48px; } .m-colmenu-btn { inset-inline-end: 18px; width: 28px; height: 32px; } }
.m-colmenu .m-mi { gap: 8px; }

/* ---------- several sort keys: the order stands before the name ---------- */
.m-table th.m-sort[data-m-sortn]::before { content: attr(data-m-sortn); display: inline-block; min-width: 13px; margin-inline-end: 4px; border-radius: 99px; background: var(--m-accent-wash); color: var(--m-accent); font-size: 9.5px; font-weight: 800; line-height: 13px; text-align: center; }
.m-table th.m-sort[data-m-sort2] { color: var(--m-accent); }
.m-table th.m-sort[data-m-sort2]::after { opacity: .7; }
.m-table th.m-sort[data-m-sort2="ascending"]::after { vertical-align: -2px; transform: rotate(225deg); }

/* ---------- date range filter ---------- */
.m-colrange { display: flex; flex-direction: column; gap: 4px; }
.m-colrange .m-colfilter { min-width: 118px; }

/* ---------- actions in the view panel ---------- */
.m-colpanel-acts { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding-block-start: 8px; border-block-start: 1px solid var(--m-line); }
.m-colpanel-acts .m-btn { justify-content: flex-start; }

/* ---------- selection bar that stays at the bottom of the window ---------- */
.m-selbar[hidden] { display: none; }
.m-selbar.m-selbar--bottom { position: sticky; inset-block-end: 10px; z-index: 4; margin: 8px 10px; border: 1px solid var(--m-line-strong); border-radius: var(--m-r); background: linear-gradient(var(--m-accent-wash), var(--m-accent-wash)), var(--m-card-solid); box-shadow: 0 18px 40px -14px rgba(var(--m-shade), calc(.9 * var(--m-sk))); }

/* ---------- row details: a side panel, a bottom sheet on a narrow screen ---------- */
.m-table--detail tbody tr:not(.m-empty-row) { cursor: pointer; }
.m-table--detail tbody tr:focus-visible { outline: 2px solid var(--m-ring); outline-offset: -2px; }
.m-modal.m-detail { place-items: stretch end; padding: 0; }
.m-detail .m-modal-box { width: min(420px, 100%); height: 100%; max-height: 100vh; max-height: 100dvh; border-radius: 0; transform: translateX(28px); }
[dir="rtl"] .m-detail .m-modal-box { transform: translateX(-28px); }
.m-detail.is-open .m-modal-box { transform: none; }
.m-detail-title { min-width: 0; overflow-wrap: anywhere; }
.m-detail-list { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 10px 16px; margin: 0; font-size: 13px; }
.m-detail-list dt { color: var(--m-text-3); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.m-detail-list dd { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; color: var(--m-text); overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .m-modal.m-detail { place-items: end stretch; }
  .m-detail .m-modal-box, [dir="rtl"] .m-detail .m-modal-box { width: 100%; height: auto; max-height: 86vh; max-height: 86dvh; border-radius: 18px 18px 0 0; transform: translateY(28px); }
  .m-detail.is-open .m-modal-box { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .m-detail .m-modal-box { transform: none; } .m-colmenu-btn { transition: none; } }

/* ---------- saved views ---------- */
.m-views-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.m-views-item { display: flex; align-items: center; gap: 6px; }
.m-views-use { flex: 1 1 0%; justify-content: flex-start; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.m-views-new { display: flex; gap: 8px; }
.m-views-new .m-input { flex: 1 1 0%; min-width: 0; }

@media print { .m-colmenu-btn { display: none; } }
