/* Компонент «таблица данных»: панель инструментов, меню колонок, таблица, страницы.
   Используется на всех страницах с большими таблицами (сейчас — аллея славы). */

/* ── Панель инструментов ── */
.dt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.dt-toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dt-updated { font-size: 13px; color: var(--dim); white-space: nowrap; }

/* Поиск */
.search {
  display: flex; align-items: center; gap: 8px; min-width: 260px;
  padding: 0 12px; height: 36px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--dim); transition: border-color .15s;
}
.search:focus-within { border-color: var(--acc); }
.search input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  color: var(--hi); font: 400 14px var(--fb);
}
.search input::placeholder { color: var(--dim); }

/* Переключатель-сегменты */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: calc(var(--radius-sm) + 3px);
}
.segmented__btn {
  padding: 6px 12px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: none; color: var(--dim); font: 600 13px var(--fb); transition: .12s;
}
.segmented__btn:hover { color: var(--hi); }
.segmented__btn.is-active { background: var(--panel); color: var(--hi); box-shadow: var(--shadow); }

/* Выпадающее меню (выбор колонок) */
.dropdown { position: relative; }
.dropdown .fa-caret-down { font-size: 11px; color: var(--dim); }
.dropdown__menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  width: 320px; max-height: min(70vh, 560px); overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.dropdown__title { padding: 8px 10px 6px; font-size: 12px; font-weight: 600; color: var(--dim); }
.dropdown__item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-size: 14px;
}
.dropdown__item:hover { background: var(--panel2); color: var(--hi); }
.dropdown__item input { width: 16px; height: 16px; accent-color: var(--acc); cursor: pointer; }
.dropdown__reset {
  width: 100%; margin-top: 4px; padding: 8px 10px; border: none; border-top: 1px solid var(--line2);
  background: none; color: var(--dim); font: 500 13px var(--fb); text-align: left; cursor: pointer;
}
.dropdown__reset:hover { color: var(--hi); }

/* ── Карточка с таблицей ── */
.dt-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.dt-scroll { overflow-x: auto; }

.dtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dtable th {
  position: relative; padding: 9px 12px; text-align: left; white-space: nowrap;
  background: var(--panel2); border-bottom: 1px solid var(--line);
  font: 600 12.5px var(--fb); color: var(--dim);
  cursor: pointer; user-select: none;
}
.dtable th:hover { color: var(--hi); }
.dtable th.is-sorted-asc, .dtable th.is-sorted-desc { color: var(--hi); }
.dtable th.is-sorted-asc::after  { content: ' ↑'; color: var(--acc); }
.dtable th.is-sorted-desc::after { content: ' ↓'; color: var(--acc); }
.dtable th.dtable__group { text-align: center; cursor: default; color: var(--text); border-bottom-color: var(--line2); }
.dtable td {
  padding: 8px 12px; white-space: nowrap; font-size: 14px; color: var(--text);
  border-bottom: 1px solid var(--line2);
}
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr:hover td { background: var(--hover); }
.dtable .is-num { text-align: right; }
.dtable .is-group-start { border-left: 1px solid var(--line); }
.dtable td.is-num { color: var(--hi); }

.dtable__gold { font-size: 11px; color: var(--mid); }
.dtable__clan { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--hi); }
.dtable__clan:hover { text-decoration: underline; text-underline-offset: 3px; }
.dtable__emblem { width: 20px; height: 20px; flex-shrink: 0; object-fit: contain; }
.dtable__excluded { color: var(--loss); font-weight: 700; cursor: help; }
.dtable tr.is-excluded td { color: var(--dim); }
.dtable th.is-static { cursor: default; }
.dtable th.is-static:hover { color: var(--dim); }
.dtable__none, .dtable__muted { color: var(--dim); }
.dtable td .dtable__muted { font-size: 13px; }
.dtable tr.is-off-alley td { background: var(--t2-soft); }
/* Значение лучше/хуже порога (проценты побед, выживания) — цвет дублирует число, не заменяет его */
.cs-good { color: var(--win); font-weight: 600; }
.cs-bad { color: var(--loss); font-weight: 600; }

/* Результат боя */
.btl-win, .btl-loss, .btl-draw { display: inline-block; padding: 2px 10px; border-radius: var(--pill); font: 600 12.5px var(--fb); }
.btl-win  { background: color-mix(in srgb, var(--win) 16%, transparent);  color: var(--win); }
.btl-loss { background: color-mix(in srgb, var(--loss) 16%, transparent); color: var(--loss); }
.btl-draw { background: var(--panel2); color: var(--text); }

/* Своя строка (игрок, записавший реплей) */
.dtable tr.is-own td { background: var(--acc-soft); }
.dtable tr.is-own td:first-child { box-shadow: inset 3px 0 var(--acc); }

/* Строка-ссылка (открывает подробности) */
.dtable tr.is-link { cursor: pointer; }
.dtable tr.is-link:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.dtable tr.is-link td:last-child { position: relative; padding-right: 26px; }
.dtable tr.is-link td:last-child::after {
  content: '›'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--dim); font-size: 18px; line-height: 1;
}
.dtable tr.is-link:hover td:last-child::after { color: var(--acc); }

/* Подсветка строки цветом (роты и т.п.): --row-tint задаётся в style строки */
.dtable tr.has-tint td { background: color-mix(in srgb, var(--row-tint) 16%, transparent); }
.dtable tr.has-tint:hover td { background: color-mix(in srgb, var(--row-tint) 24%, transparent); }
.dtable tr.has-tint td:first-child { box-shadow: inset 4px 0 var(--row-tint); }

/* Метка роты */
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 180px;
  padding: 1px 8px 1px 6px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--hi);
  background: color-mix(in srgb, var(--chip) 18%, transparent); border: 1px solid color-mix(in srgb, var(--chip) 45%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip::before { content: ''; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--chip); }

/* Легенда под таблицей */
.dt-legend { display: inline-flex; align-items: center; gap: 6px; }
.dt-legend__swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.dt-legend__swatch.is-off-alley { background: var(--t2-soft); }

.dtable__empty { padding: 32px 12px !important; text-align: center; color: var(--dim) !important; }

/* Загрузка / ошибка */
.dt-state { padding: 8px 16px 32px; text-align: center; color: var(--dim); }
.dt-state p { margin: 32px 0 12px; }
.dt-state[hidden] { display: none; }

/* ── Низ: размер страницы, счётчик, страницы ── */
.dt-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel2);
  font-size: 13px; color: var(--dim);
}
.dt-footer__size { display: inline-flex; align-items: center; gap: 8px; }
.dt-footer__size select {
  padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--hi); font: 500 13px var(--fb);
}
.pager { margin-left: auto; display: flex; gap: 4px; }
.pager__btn {
  min-width: 32px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font: 500 13px var(--fb); cursor: pointer;
}
.pager__btn:hover:not(:disabled) { color: var(--hi); border-color: var(--dim); }
.pager__btn.is-active { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.pager__btn:disabled { opacity: .4; cursor: default; }

.dt-source { margin-top: 10px; font-size: 12.5px; color: var(--dim); }
.dt-source a { text-decoration: underline; text-underline-offset: 2px; }
.dt-source a:hover { color: var(--hi); }

@media (max-width: 640px) {
  .search { min-width: 0; flex: 1; }
  .dt-toolbar__group--end { width: 100%; }
  .pager { margin-left: 0; }
}
