/* ==========================================================================
   Wide table ergonomics
   - sticky top horizontal scrollbar
   - configurable sticky columns
   - operator-friendly left/right/pan navigator
   ========================================================================== */

.wms-table-shell{
  position:relative;
  min-width:0;
  max-width:100%;
  margin: 8px 0;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel, #10151d) 78%, transparent);
  overflow: visible;
}

.wms-table-shell[data-wms-table-type="tabulator"]{
  border: 0;
  background: transparent;
  overflow: hidden;
}

.wms-table-shell[data-wms-table-type="tabulator"] .tabulator{
  max-width:100%;
}

.wms-table-toolbar{
  position: relative;
  z-index: 3;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:38px;
  padding:6px 8px;
  background: color-mix(in srgb, var(--panel, #10151d) 94%, transparent);
  border-bottom: 1px solid rgba(148, 163, 184, .16);
}

.wms-table-shell:not(.is-overflowing) .wms-table-toolbar,
.wms-table-shell:not(.is-overflowing) .wms-table-top-scroll{
  display:none;
}

.wms-table-toolbar__title{
  min-width:0;
  color: var(--muted, #94a3b8);
  font-size:11px;
  font-weight:700;
  letter-spacing:.06em;
  text-transform:uppercase;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.wms-table-toolbar__actions{
  display:flex;
  align-items:center;
  gap:6px;
  margin-left:auto;
}

.wms-table-nav-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:30px;
  padding:0 9px;
  border-radius:7px;
  border:1px solid rgba(148, 163, 184, .28);
  background: color-mix(in srgb, var(--surface-raised, #18202b) 86%, transparent);
  color: var(--text, #e5e7eb);
  font: 700 12px/1 var(--font, system-ui, sans-serif);
  cursor:pointer;
  user-select:none;
}

.wms-table-nav-btn[aria-label="Сбросить вид таблицы"]{
  color: color-mix(in srgb, var(--muted, #94a3b8) 84%, var(--text, #e5e7eb));
}

.wms-table-nav-btn:hover{
  border-color: color-mix(in srgb, var(--primary, #3b82f6) 55%, rgba(148, 163, 184, .28));
  background: color-mix(in srgb, var(--primary, #3b82f6) 16%, var(--surface-raised, #18202b));
}

.wms-table-nav-btn:active{
  transform: translateY(1px);
}

.wms-table-nav-btn.is-active{
  color:#fff;
  border-color: color-mix(in srgb, var(--primary, #3b82f6) 72%, #fff 0%);
  background: color-mix(in srgb, var(--primary, #3b82f6) 32%, var(--surface-raised, #18202b));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #3b82f6) 22%, transparent);
}

.wms-table-nav-btn--sticky{
  min-width:116px;
}

.wms-table-nav-btn--density{
  min-width:78px;
}

.wms-table-top-scroll{
  position: relative;
  z-index: 3;
  height:15px;
  overflow-x:auto;
  overflow-y:hidden;
  background: color-mix(in srgb, var(--panel-2, #0b1120) 94%, transparent);
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary, #3b82f6) 65%, #64748b) transparent;
}

.wms-table-top-scroll::-webkit-scrollbar{
  height:12px;
}

.wms-table-top-scroll::-webkit-scrollbar-track{
  background: rgba(148, 163, 184, .08);
}

.wms-table-top-scroll::-webkit-scrollbar-thumb{
  border-radius:999px;
  background: color-mix(in srgb, var(--primary, #3b82f6) 62%, #64748b);
  border: 2px solid color-mix(in srgb, var(--panel-2, #0b1120) 94%, transparent);
}

.wms-table-top-scroll__spacer{
  height:1px;
}

.wms-table-scroll{
  overflow-x:auto;
  overflow-y:visible;
  min-width:0;
  scrollbar-width: thin;
}

.wms-table-shell.is-density-compact .tabulator .tabulator-header .tabulator-col{
  min-height:34px;
}

.wms-table-shell.is-density-compact .tabulator .tabulator-cell{
  min-height:30px;
  padding-top:5px;
  padding-bottom:5px;
  line-height:1.2;
}

.wms-table-shell.is-density-compact table th,
.wms-table-shell.is-density-compact table td{
  padding-top:6px;
  padding-bottom:6px;
  line-height:1.2;
}

.wms-table-shell.is-density-compact .tabulator .tabulator-header-filter input,
.wms-table-shell.is-density-compact .tabulator .tabulator-header-filter select{
  min-height:26px;
  padding-top:3px;
  padding-bottom:3px;
}

.wms-table-scroll > table{
  min-width:max-content;
  width:100%;
  border-collapse: separate;
  border-spacing:0;
}

.wms-table-shell.is-pan-enabled .wms-table-scroll,
.wms-table-shell.is-pan-enabled .tabulator .tabulator-tableholder{
  cursor: grab;
}

.wms-table-shell.is-pan-dragging .wms-table-scroll,
.wms-table-shell.is-pan-dragging .tabulator .tabulator-tableholder{
  cursor: grabbing;
  user-select:none;
}

.wms-table-shell.is-scroll-left::before,
.wms-table-shell.is-scroll-right::after{
  content:"";
  position:absolute;
  top:54px;
  bottom:0;
  z-index:23;
  width:26px;
  pointer-events:none;
}

.wms-table-shell.is-scroll-left::before{
  left:0;
  background: linear-gradient(90deg, rgba(0,0,0,.28), transparent);
}

.wms-table-shell.is-scroll-right::after{
  right:0;
  background: linear-gradient(270deg, rgba(0,0,0,.28), transparent);
}

table [data-wms-sticky="1"],
.tabulator [data-wms-sticky="1"]{
  position: sticky !important;
  background: color-mix(in srgb, var(--panel, #10151d) 96%, #fff 0%) !important;
  box-shadow: 1px 0 0 rgba(148, 163, 184, .18);
}

table th[data-wms-sticky="1"],
.tabulator .tabulator-header [data-wms-sticky="1"]{
  z-index:22 !important;
  background: color-mix(in srgb, var(--panel-2, #0b1120) 96%, #fff 0%) !important;
}

table td[data-wms-sticky="1"]{
  z-index:18;
}

.tabulator .tabulator-row .tabulator-cell[data-wms-sticky="1"]{
  z-index:12 !important;
}

.tabulator .tabulator-col.tabulator-frozen,
.tabulator .tabulator-cell.tabulator-frozen{
  background: color-mix(in srgb, var(--panel, #10151d) 96%, #fff 0%) !important;
  box-shadow: 1px 0 0 rgba(148, 163, 184, .18);
}

.tabulator .tabulator-col.tabulator-frozen{
  background: color-mix(in srgb, var(--panel-2, #0b1120) 96%, #fff 0%) !important;
  z-index: 18 !important;
}

[data-theme="light"] .wms-table-shell{
  border-color: rgba(15, 23, 42, .14);
  background:#fff;
}

[data-theme="light"] .wms-table-toolbar{
  background: rgba(248, 250, 252, .96);
  border-bottom-color: rgba(15, 23, 42, .12);
}

[data-theme="light"] .wms-table-top-scroll{
  background: rgba(241, 245, 249, .98);
  border-bottom-color: rgba(15, 23, 42, .12);
}

[data-theme="light"] table [data-wms-sticky="1"],
[data-theme="light"] .tabulator [data-wms-sticky="1"]{
  background:#fff !important;
}

[data-theme="light"] table th[data-wms-sticky="1"],
[data-theme="light"] .tabulator .tabulator-header [data-wms-sticky="1"]{
  background:#f8fafc !important;
}

[data-theme="light"] .tabulator .tabulator-col.tabulator-frozen,
[data-theme="light"] .tabulator .tabulator-cell.tabulator-frozen{
  background:#fff !important;
}

[data-theme="light"] .tabulator .tabulator-col.tabulator-frozen{
  background:#f8fafc !important;
}

@media (max-width: 760px){
  .wms-table-toolbar{
    flex-wrap:wrap;
  }

  .wms-table-toolbar__title{
    flex:1 1 100%;
  }

  .wms-table-toolbar__actions{
    width:100%;
    justify-content:space-between;
  }

  .wms-table-nav-btn{
    min-width:38px;
  }

  .wms-table-nav-btn--sticky{
    flex:1 1 auto;
  }

  .wms-table-nav-btn--density{
    flex:1 1 auto;
  }

}
