/* TCMH Sofascore — Bảng xếp hạng
   Dùng lại bộ biến màu của tcmh-sofascore.css (--tc-*), nên tự động ăn theo
   data-theme="light|dark" của khối cha.

   Nguyên tắc responsive: bảng KHÔNG bị bóp chữ. Trên màn hình hẹp, cột hạng +
   tên đội dính bên trái, phần số cuộn ngang; các cột phụ (hiệu số, set, tỉ lệ,
   phong độ) ẩn đi và bật lại bằng nút "Đầy đủ". */

/* ---------- Bộ lọc ---------- */

.tcmh-st__filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tcmh-st__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tcmh-st__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--tc-muted);
}

.tcmh-st__select,
.tcmh-st__input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--tc-line);
  border-radius: var(--tc-r-sm);
  background: var(--tc-surface);
  color: var(--tc-ink);
  font-size: 14px;
  line-height: 1.2;
  appearance: none;
}

.tcmh-st__select {
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.tcmh-st__select:focus,
.tcmh-st__input:focus {
  border-color: var(--tc-brand);
  outline: none;
}

.tcmh-st__reset {
  align-self: end;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--tc-r-sm);
  background: var(--tc-brand-soft);
  color: var(--tc-ink-2);
  font-size: 13px;
  font-weight: 600;
}

.tcmh-st__reset:hover { color: var(--tc-ink); }

/* ---------- Thẻ một bảng xếp hạng ---------- */

.tcmh-st__card {
  margin-bottom: 12px;
  border-radius: var(--tc-r-md);
  background: var(--tc-surface);
  box-shadow: var(--tc-shadow-sm);
  overflow: hidden;
}

.tcmh-st__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--tc-line);
}

.tcmh-st__logo {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  object-fit: contain;
}

.tcmh-st__titles { min-width: 0; flex: 1 1 auto; }

.tcmh-st__name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--tc-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tcmh-st__meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--tc-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tcmh-st__card.is-vn .tcmh-st__name::after {
  content: "VN";
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--tc-brand-soft);
  color: var(--tc-ink-2);
  font-size: 10px;
  vertical-align: middle;
}

.tcmh-st__toggle {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--tc-brand-soft);
  color: var(--tc-ink-2);
  font-size: 12px;
  font-weight: 600;
  display: none;
}

/* ---------- Bảng ---------- */

.tcmh-st__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.tcmh-st__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tcmh-st__table th,
.tcmh-st__table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--tc-line);
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

.tcmh-st__table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--tc-surface-2);
  color: var(--tc-muted);
  font-size: 11px;
  font-weight: 600;
}

.tcmh-st__table tbody tr:last-child td { border-bottom: 0; }
.tcmh-st__table tbody tr:hover td { background: var(--tc-surface-2); }

/* Cột hạng + tên đội dính trái khi cuộn ngang */
.tcmh-st__c-team {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 158px;
  max-width: 220px;
  padding-left: 12px !important;
  background: var(--tc-surface);
  text-align: left !important;
}

.tcmh-st__table thead .tcmh-st__c-team {
  z-index: 4;
  background: var(--tc-surface-2);
}

.tcmh-st__table tbody tr:hover .tcmh-st__c-team { background: var(--tc-surface-2); }

.tcmh-st__team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tcmh-st__rank {
  flex: 0 0 20px;
  color: var(--tc-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.tcmh-st__crest {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  object-fit: contain;
}

.tcmh-st__tname {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--tc-ink);
}

/* Đội đủ điều kiện đi tiếp — vạch màu bám mép trái */
.tcmh-st__row.is-qualified .tcmh-st__c-team {
  box-shadow: inset 3px 0 0 var(--tc-win);
}

.tcmh-st__pts { font-weight: 700; color: var(--tc-ink); }

/* Phong độ 5 trận gần nhất */
.tcmh-st__form {
  display: inline-flex;
  gap: 2px;
}

.tcmh-st__f {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.tcmh-st__f--w { background: var(--tc-win); }
.tcmh-st__f--l { background: var(--tc-live); }
.tcmh-st__f--d { background: var(--tc-muted); }

.tcmh-st__foot {
  padding: 8px 14px 10px;
  color: var(--tc-muted);
  font-size: 11px;
}

/* ---------- Trạng thái rỗng / nút xem thêm ---------- */

.tcmh-st__empty {
  padding: 28px 16px;
  border-radius: var(--tc-r-md);
  background: var(--tc-surface);
  color: var(--tc-ink-2);
  text-align: center;
  font-size: 14px;
}

.tcmh-st__empty b { display: block; margin-bottom: 4px; color: var(--tc-ink); }

.tcmh-st__more { margin-top: 4px; text-align: center; }

.tcmh-st__morebtn {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--tc-brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.tcmh-st__morebtn[disabled] { opacity: .55; cursor: default; }

/* ---------- Màn hình hẹp ---------- */

@media (max-width: 700px) {
  .tcmh-st { padding: 12px; }

  .tcmh-st__filters { grid-template-columns: 1fr 1fr; }
  .tcmh-st__field--search { grid-column: 1 / -1; }
  .tcmh-st__reset { grid-column: 1 / -1; }

  .tcmh-st__toggle { display: inline-block; }

  /* Cột phụ ẩn mặc định; bật lại bằng nút "Đầy đủ" trên đầu mỗi bảng */
  .tcmh-st__card:not(.is-wide) [data-opt="1"] { display: none; }

  .tcmh-st__table th,
  .tcmh-st__table td { padding: 8px 5px; font-size: 12px; }

  .tcmh-st__c-team {
    min-width: 132px;
    max-width: 160px;
    padding-left: 10px !important;
  }

  .tcmh-st__crest { width: 18px; height: 18px; flex-basis: 18px; }
  .tcmh-st__name { white-space: normal; }
}

@media (max-width: 380px) {
  .tcmh-st__filters { grid-template-columns: 1fr; }
  .tcmh-st__c-team { min-width: 118px; }
  .tcmh-st__rank { flex-basis: 16px; }
}

/* ---------- Bảng xếp hạng trước trận (panel chi tiết) ---------- */
/* Bảng cũ trong .tcmh-body tràn ngang trên điện thoại — cho cuộn thay vì vỡ */
@media (max-width: 700px) {
  .tcmh-sofa table { max-width: 100%; }
  .tcmh-sofa .tcmh-body table { display: block; overflow-x: auto; }
}
