/* Excel-artige Mehrfachfilter in den Tabellenköpfen AbtNr und Hersteller */
.column-filter-trigger,
.column-sort-trigger {
  display: inline-flex;
  width: auto !important;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-left: 0;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  color: #c8d8ef;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition:
    background 140ms ease-out,
    border-color 140ms ease-out,
    color 140ms ease-out;
}

.database-table thead .column-action-header {
  align-items: stretch;
  text-align: center;
}

.database-table thead .column-action-header-label,
.database-table thead .column-action-header-control {
  display: flex;
  width: 100% !important;
  align-items: center;
  justify-content: center;
}

.database-table thead .column-action-header-label {
  flex: 1;
  min-height: 20px;
}

.database-table thead .column-action-header-control {
  min-height: 24px;
}

.column-filter-trigger:hover,
.column-filter-trigger:focus-visible,
.column-filter-trigger.is-active,
.database-table thead .column-sort-header:hover .column-sort-trigger,
.database-table thead .column-sort-header:focus-visible .column-sort-trigger,
.database-table thead .column-sort-header.active .column-sort-trigger {
  color: #dceaff;
  border-color: #5b9dff;
  background: rgba(91, 157, 255, 0.22);
  outline: none;
}

/* a4-layout.css dehnt span/div in den Preis-/Geändert-Köpfen mit !important
   auf volle Breite und überschreibt bei „Geändert“ zusätzlich Rahmen und
   Hintergrund. Diese gemeinsame Steuerfläche muss deshalb gezielt stärker sein. */
.database-table thead tr th .column-sort-trigger {
  display: inline-flex !important;
  width: auto !important;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 2px 5px !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 4px !important;
  color: #c8d8ef !important;
  background: rgba(255, 255, 255, 0.05) !important;
  box-shadow: none !important;
  font-size: 13px !important;
  line-height: 1 !important;
}

/* „Geändert“ ist die neunte Spalte. Ihre A4-Regeln verwenden :nth-child(9)
   und brauchen daher dieselbe Spezifität, damit auch dort der Rahmen bleibt. */
.database-table thead tr th:nth-child(9) .column-sort-trigger {
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  background: rgba(255, 255, 255, 0.05) !important;
}

/* Der ganze Sortierkopf bleibt klickbar, reagiert aber optisch wie die
   Filterköpfe: neutrale Kopfaufhellung + hervorgehobene Steuerfläche. */
.database-table thead tr:hover {
  background-color: transparent !important;
  background-image: none !important;
}

.database-table thead th:hover:has(.column-sort-header) {
  background: #2b2b2b !important;
}

.database-table thead .column-sort-header:hover,
.database-table thead tr th:nth-child(9) .column-header.column-sort-header[id]:hover {
  background: transparent !important;
  box-shadow: none !important;
}

.database-table thead tr th .column-sort-header:hover .column-sort-trigger,
.database-table thead tr th .column-sort-header:focus-visible .column-sort-trigger,
.database-table thead tr th .column-sort-header.active .column-sort-trigger {
  color: #dceaff !important;
  border-color: #5b9dff !important;
  background: rgba(91, 157, 255, 0.22) !important;
}

.database-table thead tr th:nth-child(9) .column-sort-header:hover .column-sort-trigger,
.database-table thead tr th:nth-child(9) .column-sort-header:focus-visible .column-sort-trigger,
.database-table thead tr th:nth-child(9) .column-sort-header.active .column-sort-trigger {
  border-color: #5b9dff !important;
  background: rgba(91, 157, 255, 0.22) !important;
}

.database-table thead .column-sort-header:focus-visible {
  outline: 2px solid rgba(91, 157, 255, 0.55);
  outline-offset: -2px;
}

.column-filter-trigger svg {
  width: 13px !important;
  height: 13px !important;
  fill: currentColor;
}

.column-filter-count {
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  color: #10223d;
  background: #9dc5ff;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
}

.column-filter-popover {
  position: fixed;
  z-index: 45000;
  display: grid;
  grid-template-rows: auto auto auto minmax(120px, 320px) auto;
  max-height: min(620px, calc(100vh - 24px));
  overflow: hidden;
  border: 1px solid #31445f;
  border-radius: 7px;
  color: #ecf3fc;
  background: #182231;
  box-shadow:
    0 18px 44px rgba(3, 12, 24, 0.42),
    0 2px 10px rgba(3, 12, 24, 0.34);
  font-size: 13px;
}

.column-filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
}

.column-filter-heading {
  border-bottom: 1px solid #2c3c52;
}

.column-filter-heading > strong {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.column-filter-heading-actions {
  display: flex;
  width: auto !important;
  flex: none;
  align-items: center;
  gap: 6px;
}

.column-filter-heading-actions button {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.column-filter-close {
  width: 28px;
  min-width: 28px;
  height: 30px;
  min-height: 30px;
  padding: 0 !important;
  border: 0;
  color: #aebdd0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.column-filter-close:hover,
.column-filter-close:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.column-filter-search {
  width: calc(100% - 24px);
  margin: 10px 12px 8px;
  padding: 8px 9px;
  border: 1px solid #405571;
  border-radius: 4px;
  color: #eef5ff;
  background: #101a27;
}

.column-filter-search:focus {
  border-color: #5b9dff;
  outline: 2px solid rgba(91, 157, 255, 0.22);
}

.column-filter-select-all,
.column-filter-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 12px;
  cursor: pointer;
}

.column-filter-select-all {
  grid-template-columns: 18px minmax(0, 1fr);
  border-bottom: 1px solid #2c3c52;
  font-weight: 700;
}

.column-filter-options {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0;
}

.column-filter-option:hover {
  background: rgba(91, 157, 255, 0.12);
}

/* display:grid würde sonst das native [hidden]-Verhalten überschreiben. */
.column-filter-option[hidden] {
  display: none !important;
}

.column-filter-option input,
.column-filter-select-all input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #5b9dff;
}

.column-filter-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-filter-option-count {
  color: #91a2b8;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.column-filter-status {
  padding: 7px 12px;
  border-top: 1px solid #2c3c52;
  color: #9fb0c5;
  font-size: 11px;
}

.column-filter-reset {
  border: 1px solid #405571;
  color: #c9d5e5;
  background: transparent;
}

.column-filter-apply {
  border: 1px solid #5b9dff;
  color: #10223d;
  background: #8fbdff;
}

.column-filter-apply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .column-filter-popover {
    left: 8px !important;
    right: 8px;
    width: auto !important;
  }
}

@media (max-width: 380px) {
  .column-filter-heading {
    gap: 4px;
    padding: 7px 6px;
  }

  .column-filter-heading > strong {
    font-size: clamp(10px, 3.2vw, 12px);
  }

  .column-filter-heading-actions {
    gap: 3px;
  }

  .column-filter-heading-actions button {
    min-height: 28px;
    padding: 4px;
    font-size: 10.5px;
  }

  .column-filter-close {
    width: 24px;
    min-width: 24px;
    height: 28px;
    min-height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .column-filter-trigger,
  .column-sort-trigger {
    transition: none;
  }
}
