/**
 * my.ahf.cloud — Tabellen (Referenz: Hubtisch-Katalog)
 * Markup: .table-wrap.table-wrap--sticky-head > table.data-table
 */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.table-wrap--sticky-head {
  max-height: min(70vh, 720px);
  overflow: auto;
  background: #f3f4f6;
}

html[data-theme="dark"] .table-wrap--sticky-head {
  background: #243044;
}

.table-wrap--sticky-head .data-table tbody td {
  background: var(--surface);
}

.component-access-select {
  min-width: 11rem;
  max-width: 100%;
  font: inherit;
  font-size: var(--ui-font-body, 14px);
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.config-save-hint.is-ok {
  color: var(--accent, #009493);
}

.config-save-hint.is-error {
  color: #b42318;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: var(--ui-font-body, calc(14px * var(--text-scale, 1)));
  line-height: 1.4;
  color: var(--text);
}

.data-table caption {
  caption-side: top;
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text);
}

.data-table thead th {
  position: relative;
  padding: 0.45rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: var(--ui-font-caption, calc(12px * var(--text-scale, 1)));
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f3f4f6;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  line-height: 1.2;
  border-radius: var(--radius-sm, 6px);
}

.th-sort:hover {
  color: var(--text);
}

.th-sort:focus-visible {
  outline: 2px solid var(--accent, #009493);
  outline-offset: 2px;
}

.th-sort--num {
  width: 100%;
  justify-content: flex-end;
}

.th-sort__icons {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.th-sort__chev {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.28;
}

.th-sort__chev--up {
  border-bottom: 5px solid currentColor;
}

.th-sort__chev--down {
  border-top: 5px solid currentColor;
}

th[aria-sort="ascending"] .th-sort__chev--up,
th[aria-sort="descending"] .th-sort__chev--down {
  opacity: 1;
  color: var(--accent, #009493);
}

th[aria-sort="ascending"] .th-sort,
th[aria-sort="descending"] .th-sort {
  color: var(--text);
}

.table-wrap--sticky-head .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

.data-table tbody td {
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(0, 148, 147, 0.04);
}

.data-table--zebra tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}

.data-table--zebra tbody tr:nth-child(even):hover td {
  background: rgba(0, 148, 147, 0.06);
}

/* Alias — gleiche Dichte wie Standard (Hubtisch) */
.data-table--compact {
  font-size: inherit;
}

.data-table .col-num,
.data-table th.col-num,
.data-table td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .col-center {
  text-align: center;
}

.data-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

.cell-title {
  display: block;
  font-weight: 500;
  color: var(--text);
  max-width: 28rem;
}

.cell-sub,
.cell-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--ui-font-caption, 12px);
  color: var(--muted);
  line-height: 1.35;
}

.cell-mono {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: inherit;
  color: var(--muted);
}

.cell-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--badge-radius, var(--radius-sm));
  font-size: var(--ui-font-caption, 12px);
  font-weight: 500;
  background: #eef2ff;
  color: #3730a3;
}

.cell-badge--accent {
  background: #ecfdfd;
  color: #007a79;
}

.data-table tbody tr.is-empty td {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-style: normal;
}

.data-table a.row-link {
  color: inherit;
  text-decoration: none;
}

.data-table a.row-link:hover .cell-title {
  color: var(--accent);
}

@media (max-width: 640px) {
  .data-table thead th,
  .data-table tbody td {
    padding: 0.4rem 0.45rem;
  }
}
