/* data_table.css — styles for the shared BBDataTable component.
 * Uses the base.css design tokens. The base td rule deliberately sets no
 * text-align or color, so per-cell classes the page passes in (rk-value,
 * rk-range, conf-*, tier-chip, etc.) keep working unchanged.
 */

.bbdt-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.bbdt-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 190px;
  max-width: 300px;
}
.bbdt-search .bbdt-mag {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.bbdt-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 9px 12px 9px 34px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-stack, inherit);
}
.bbdt-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 156, 44, 0.15);
}
.bbdt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.bbdt-flabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
}
.bbdt-seg {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  padding: 2px;
}
.bbdt-seg button {
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: color 0.14s, background 0.14s;
}
.bbdt-seg button[aria-pressed="true"] {
  color: #fff;
  background: rgba(243, 156, 44, 0.20);
}

.bbdt-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.bbdt-scroll { overflow-x: auto; }

.bbdt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bbdt-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-page);
  border-bottom: 1px solid var(--stroke);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0;
  text-align: left;
}
.bbdt-table thead th.bbdt-plain { padding: 11px 12px; }
.bbdt-table thead th.bbdt-r { text-align: right; }

.bbdt-table th .bbdt-sort {
  width: 100%;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bbdt-table th.bbdt-r .bbdt-sort { justify-content: flex-end; }
.bbdt-table th .bbdt-sort:hover { color: var(--text-2); }
.bbdt-table th[aria-sort="ascending"] .bbdt-sort,
.bbdt-table th[aria-sort="descending"] .bbdt-sort { color: var(--accent); }

.bbdt-caret { width: 9px; height: 9px; opacity: 0.35; fill: currentColor; flex: none; }
.bbdt-table th[aria-sort="ascending"] .bbdt-caret,
.bbdt-table th[aria-sort="descending"] .bbdt-caret { opacity: 1; }
.bbdt-table th[aria-sort="descending"] .bbdt-caret { transform: rotate(180deg); }

/* base cell: padding + border only. No text-align/color, so page-supplied
   cell classes (rk-value, rk-range, conf-*, etc.) keep their own styling. */
.bbdt-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke-soft);
  vertical-align: middle;
}
.bbdt-table tbody td.bbdt-r { text-align: right; }
.bbdt-table tbody tr:hover td { background: rgba(243, 156, 44, 0.05); }
.bbdt-table tbody tr:last-child td { border-bottom: 0; }

.bbdt-empty {
  padding: 26px 12px !important;
  text-align: center !important;
  color: var(--text-muted);
  font-style: italic;
}

/* generic up/down movement coloring (token-based, no hardcoded hex) */
.bbdt-up { color: var(--accent-good); font-weight: 600; }
.bbdt-dn { color: var(--accent-bad); font-weight: 600; }

/* ------------------------------------------------------------------ *
 * Mobile: reflow the shared data table into stacked cards.
 * Each row becomes a card; each cell shows its column label (from the
 * data-label the component now emits) so nothing needs horizontal
 * scrolling to read. The player/name cell spans full width as a header.
 * ------------------------------------------------------------------ */
@media (max-width: 640px) {
  .bbdt-scroll { overflow-x: visible; }
  .bbdt-table { font-size: 13px; }

  .bbdt-table thead { display: none; }

  .bbdt-table,
  .bbdt-table tbody,
  .bbdt-table tr,
  .bbdt-table td { display: block; width: 100%; }

  .bbdt-table tbody tr {
    background: var(--bg-panel);
    border: 1px solid var(--stroke-soft);
    border-radius: var(--radius-md, 12px);
    padding: 4px 12px 8px;
    margin-bottom: 10px;
  }
  .bbdt-table tbody tr:last-child td { border-bottom: 1px solid var(--stroke-soft); }

  .bbdt-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
    padding: 7px 0;
    border-bottom: 1px solid var(--stroke-soft);
    white-space: normal;
  }
  .bbdt-table tbody tr td:last-child { border-bottom: 0; }

  /* the column label, injected before the value */
  .bbdt-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-faint);
    white-space: nowrap;
  }
  /* cells with no label (icons, spacers) shouldn't reserve the label gap */
  .bbdt-table tbody td:not([data-label])::before { content: ""; }

  /* the player/name cell: full-width card header, no label prefix */
  .bbdt-table tbody td.rk-player,
  .bbdt-table tbody td.bbdt-primary {
    justify-content: flex-start;
    text-align: left;
    font-size: 15px;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--stroke);
  }
  .bbdt-table tbody td.rk-player::before,
  .bbdt-table tbody td.bbdt-primary::before { content: ""; }

  /* right-aligned numeric cells already read well in the flex row */
  .bbdt-table tbody td.bbdt-r { text-align: right; }

  /* keep the toolbar controls from crowding */
  .bbdt-toolbar { gap: 8px; }
  .bbdt-search { max-width: none; min-width: 0; flex: 1 1 100%; }
  .bbdt-count { margin-left: 0; }
}
