/**
 * Match detail — H2H tab: same row layout as templates/h2h.html (recent-list + h2h-table-row).
 * Scores are plain bold text (no coloured pills), matching the H2H history tab in h2h.html.
 */

#h2h-meetings .match-detail-h2h-row-pending {
  display: none !important;
}

#h2h-meetings .match-detail-h2h-controls {
  text-align: center;
  margin: 10px 0 6px;
}

#h2h-meetings .match-detail-h2h-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #fff);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#h2h-meetings .match-detail-h2h-more:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

#h2h-meetings .recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 4px 2px 12px;
  max-height: 70vh;
  overflow-y: auto;
}

#h2h-meetings .recent-list .recent-row:last-child {
  border-bottom: none;
}

#h2h-meetings a.h2h-table-row {
  text-decoration: none;
  color: inherit;
  display: grid;
}

#h2h-meetings .h2h-table-row {
  display: grid;
  grid-template-columns: 60px 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 20px;
  border-bottom: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.012);
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
}

#h2h-meetings .h2h-table-row:hover {
  background: var(--table-hover-bg, rgba(98, 150, 112, 0.14));
  box-shadow: inset 3px 0 0 var(--table-hover-accent, rgba(127, 184, 143, 0.85));
  transform: translateY(-1px);
}

#h2h-meetings .h2h-cell-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

#h2h-meetings .h2h-cell-date-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

#h2h-meetings .h2h-cell-date-year {
  font-size: 0.7rem;
  color: var(--text-muted);
}

#h2h-meetings .h2h-comp-logo {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.95;
}

#h2h-meetings .h2h-cell-team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(2) {
  justify-content: flex-end;
  text-align: right;
  padding-right: 6px;
}

#h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(2) .h2h-team-name {
  order: 1;
}
#h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(2) .h2h-team-logo {
  order: 2;
}

#h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(4) {
  justify-content: flex-start;
  text-align: left;
  padding-left: 6px;
}

#h2h-meetings .h2h-team-logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
}

#h2h-meetings .h2h-team-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#h2h-meetings .h2h-cell-score {
  text-align: center;
}

#h2h-meetings .h2h-score-box {
  display: inline-block;
  padding: 0;
  background: transparent !important;
  border: none !important;
  border-radius: 0;
  color: var(--text-primary, rgba(255, 255, 255, 0.92));
  font-weight: 800;
  font-size: 1rem;
  min-width: 0;
  text-align: center;
  letter-spacing: 0.02em;
  box-shadow: none !important;
}

#h2h-meetings .h2h-score-box.is-placeholder {
  color: var(--text-muted);
  font-weight: 600;
}

#h2h-meetings .recent-row .h2h-cell-date {
  gap: 0;
  font-size: var(--fs-xs);
}

#h2h-meetings .recent-row .h2h-comp-logo {
  margin-bottom: 1px;
}

#h2h-meetings .recent-row .h2h-cell-date-time {
  margin-top: 1px;
}

#h2h-meetings .recent-row .h2h-cell-team {
  gap: 7px;
}

#h2h-meetings .recent-list .recent-row:not(:last-child) {
  margin-bottom: 6px;
}

#h2h-meetings .match-detail-h2h-empty {
  text-align: center;
  color: var(--text-muted, #888);
  padding: 28px 12px;
  margin: 0;
}

@media (max-width: 768px) {
  #h2h-meetings .h2h-team-name {
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    max-height: 2.4em;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@media (max-width: 700px) {
  #h2h-meetings .h2h-table-row {
    grid-template-columns: 90px 1.4fr 64px 1.4fr;
    gap: 8px;
    padding: 12px 14px;
  }
  #h2h-meetings .h2h-cell-team {
    gap: 10px;
  }
  #h2h-meetings .recent-row .h2h-cell-team {
    gap: 7px;
  }
  #h2h-meetings .h2h-team-name {
    font-size: var(--fs-sm);
  }
  #h2h-meetings .h2h-score-box {
    font-size: var(--fs-sm);
  }
}

@media (max-width: 490px) {
  #h2h-meetings .h2h-table-row {
    grid-template-columns: 78px 1fr 54px 1fr;
    gap: 6px;
    padding: 10px 10px;
  }
  #h2h-meetings .h2h-cell-team {
    gap: 6px;
  }
  #h2h-meetings .recent-row .h2h-cell-team {
    gap: 5px;
  }
  #h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(2) {
    padding-right: 3px;
  }
  #h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(4) {
    padding-left: 3px;
  }
  #h2h-meetings .h2h-team-logo {
    width: 20px;
    height: 20px;
  }
  #h2h-meetings .h2h-team-name {
    font-size: var(--fs-xs);
  }
  #h2h-meetings .recent-row .h2h-cell-date {
    font-size: var(--fs-xs);
  }
  #h2h-meetings .h2h-score-box {
    font-size: var(--fs-sm);
  }
}

/* Match h2h.html tight mobile tuning (~430px) */
@media (max-width: 430px) {
  #h2h-meetings .h2h-table-row {
    grid-template-columns: 45px 1fr 40px 1fr;
    gap: 4px;
    padding: 8px 6px;
    margin-bottom: 6px;
  }
  #h2h-meetings .h2h-cell-team {
    gap: 4px;
    min-width: 0;
  }
  #h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(2) {
    padding-right: 2px;
  }
  #h2h-meetings .h2h-table-row .h2h-cell-team:nth-child(4) {
    padding-left: 2px;
  }
  #h2h-meetings .h2h-team-logo {
    width: 18px;
    height: 18px;
  }
  #h2h-meetings .h2h-team-name {
    font-size: var(--fs-xs);
    white-space: normal;
    line-height: 1.1;
    overflow: visible;
    text-overflow: clip;
    min-width: 40px;
  }
  #h2h-meetings .h2h-score-box {
    font-size: var(--fs-xs);
    min-width: 0;
  }
  #h2h-meetings .h2h-cell-date {
    font-size: var(--fs-xs);
  }
  #h2h-meetings .h2h-cell-date-year {
    display: none;
  }
}

/* Light theme */
[data-theme="light"] #h2h-meetings .match-detail-h2h-more {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #1e293b;
}

[data-theme="light"] #h2h-meetings .match-detail-h2h-more:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

[data-theme="light"] #h2h-meetings .h2h-team-name,
[data-theme="light"] #h2h-meetings .h2h-score-box,
[data-theme="light"] #h2h-meetings .h2h-cell-date,
[data-theme="light"] #h2h-meetings .h2h-cell-date-time,
[data-theme="light"] #h2h-meetings .h2h-cell-date-year {
  color: #191c1d !important;
}

[data-theme="light"] #h2h-meetings .h2h-score-box.is-placeholder {
  color: #64748b !important;
}

[data-theme="light"] #h2h-meetings .recent-row {
  border-color: #e2e8f0 !important;
}

[data-theme="light"] #h2h-meetings .h2h-table-row:hover {
  background: var(--table-hover-bg, rgba(74, 124, 89, 0.1));
  /* Align with matches page: keep hover tint, drop inset bar (reads as outline on rounded rows) */
  box-shadow: none;
}

[data-theme="light"] #h2h-meetings .match-detail-h2h-empty {
  color: #64748b !important;
}
