/* ============================
   Heraklion Padel Leaderboard
   ============================ */

body {
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: #f4f6fb;
  color: #222;
  margin: 0;
}

/* ======= Buttons ======= */
.category-buttons, .category-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px auto;
}

.category-button, .filter-button {
  border: 2px solid #1976d2;
  background: white;
  color: #1976d2;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-button.active, .filter-button.active {
  background: #1976d2;
  color: white;
  box-shadow: 0 4px 8px rgba(25,118,210,0.3);
  position: relative;
}

.category-button:hover, .filter-button:hover {
  background: #1976d2;
  color: white;
}

.leaderboard-men-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.leaderboard-men-cluster .category-button {
  flex: 1 1 auto;
}

.rating-info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.rating-info-trigger {
  width: 28px;
  height: 28px;
  border: 2px solid #1976d2;
  border-radius: 50%;
  background: #fff;
  color: #1976d2;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.rating-info-trigger:hover,
.rating-info-trigger:focus {
  background: #1976d2;
  color: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
}

.rating-info-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 30;
  width: min(92vw, 560px);
  max-height: min(78vh, 680px);
  overflow: auto;
  background: #fff;
  color: #1f2937;
  border: 1px solid rgba(25, 118, 210, 0.25);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
  border-radius: 8px;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  text-align: left;
}

.rating-info-wrap:hover .rating-info-popover,
.rating-info-wrap:focus-within .rating-info-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.rating-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 10px;
}

.rating-info-table th,
.rating-info-table td {
  border-bottom: 1px solid #e5edf8;
  padding: 5px 6px;
  white-space: nowrap;
}

.rating-info-table th {
  color: #0d47a1;
  font-size: 11px;
  text-transform: uppercase;
}

.rating-info-table td:nth-child(3) {
  color: #0d47a1;
  font-weight: 800;
}

.rating-info-formula {
  border-top: 1px solid #e5edf8;
  padding-top: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.rating-info-formula strong {
  color: #0d47a1;
  display: block;
  margin-bottom: 4px;
}

.rating-info-formula p {
  margin: 4px 0;
}

.court-filter {
  width: min(95vw, 320px);
  margin: 8px auto 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.court-filter label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0d47a1;
}

.court-filter select {
  width: 100%;
  border: 2px solid #1976d2;
  border-radius: 8px;
  background: white;
  color: #0d47a1;
  font: inherit;
  font-weight: 600;
  padding: 10px 12px;
  outline: none;
  box-sizing: border-box;
}

.court-filter select:focus {
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
}

/* ✅ Τικ στο ενεργό κουμπί */
.category-button.active::before, .filter-button.active::before {
  content: "✓";
  font-weight: bold;
  font-size: 1.1em;
  margin-right: 8px;
}

/* ======= Tables ======= */
.leaderboard-table {
  width: 95%;
  margin: 20px auto;
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.leaderboard-table th {
  background: linear-gradient(90deg, #0d47a1, #1976d2);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 14px;
  padding: 10px;
}

.leaderboard-table td {
  text-align: center;
  padding: 10px;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}

.leaderboard-table tr:nth-child(even) {
  background: #f8fbff;
}

.leaderboard-table tr:hover {
  background: #e3f2fd;
}

/* ======= Player Cell ======= */
td.name-cell {
  text-align: left;
  min-width: 0;
}

.leaderboard-player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.leaderboard-player-cell img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1976d2;
}

.leaderboard-name-wrap {
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  line-height: 1.2;
}

.leaderboard-name-link {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-name-mobile {
  display: none;
}

.player-category {
  background: #1976d2;
  color: white;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

/* Χρώματα ανά κατηγορία */
.player-category[data-cat="A"] { background: #e53935; }
.player-category[data-cat="B"] { background: #fb8c00; }
.player-category[data-cat="C"] { background: #43a047; }
.player-category[data-cat="D"] { background: #1e88e5; }
.player-category[data-cat="E"] { background: #8e24aa; }

/* ======= Final Perfect Mobile Alignment (FULL FIX v3) ======= */
@media (max-width: 768px) {
  /* --- Reset base layout --- */
  html,
  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  main {
    width: 100vw;
    margin: 0;
    padding: 0;
  }

  /* ✅ Αφαιρούμε padding/margin ΜΟΝΟ από sections */
  main > section {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* --- Κουμπιά πάνω (Men / Women / Mixed / Americano) --- */
  .category-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin: 8px auto;
    width: 96vw; /* ✅ Κεντραρισμένα */
    padding: 0;
    box-sizing: border-box;
  }

  .category-button {
    font-size: 10px;
    padding: 6px 0;
    border-radius: 5px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- Κουμπιά φίλτρων (Everyone / A / B / C / D / E) --- */
  .category-filters {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin: 6px auto 10px;
    width: 96vw;
    padding: 0;
    box-sizing: border-box;
  }

  .filter-button {
    font-size: 10px;
    padding: 5px 0;
    border-radius: 5px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- Πίνακας --- */
  .court-filter {
    width: 96vw;
    margin: 4px auto 10px;
    gap: 4px;
  }

  .court-filter label {
    font-size: 11px;
  }

  .court-filter select {
    font-size: 11px;
    padding: 8px 10px;
    border-radius: 6px;
  }

  table.leaderboard-table {
    width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    table-layout: fixed;

    border-radius: 6px;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 10px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    box-sizing: border-box;
    font-size: 9px;
    padding: 2px 1px;
  }

  .leaderboard-table th:nth-child(1),
  .leaderboard-table td:nth-child(1) {
    width: 4.5vw;
  }

  .leaderboard-table th:nth-child(2),
  .leaderboard-table td:nth-child(2) {
    width: 34vw;
  }

  .leaderboard-table th:nth-child(3),
  .leaderboard-table td:nth-child(3) {
    width: 9.5vw;
  }

  .leaderboard-table th:nth-child(4),
  .leaderboard-table td:nth-child(4) {
    width: 7vw;
    font-size: 8px;
  }

  .leaderboard-table th:nth-child(5),
  .leaderboard-table td:nth-child(5),
  .leaderboard-table th:nth-child(6),
  .leaderboard-table td:nth-child(6) {
    width: 4.8vw;
  }

  .leaderboard-table th:nth-child(n + 7),
  .leaderboard-table td:nth-child(n + 7) {
    width: 5.2vw;
    font-size: 8px;
  }

  .leaderboard-player-cell {
    align-items: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .leaderboard-player-cell img {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-width: 1px;
  }

  td.name-cell {
    max-width: none;
    min-width: 0;
    overflow: hidden;
  }

  .leaderboard-name-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .leaderboard-name-link {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    vertical-align: bottom;
    font-size: 9px;
  }

  .leaderboard-name-full {
    display: none;
  }

  .leaderboard-name-mobile {
    display: inline;
  }

  .player-category {
    flex: 0 0 auto;
    margin-left: 0;
    padding: 1px 3px;
    border-radius: 4px;
    font-size: 9px;
    letter-spacing: 0;
  }

  h2 {
    font-size: 14px;
    text-align: center;
    margin: 6px 0;
  }

  .leaderboard-men-cluster {
    gap: 3px;
    min-width: 0;
  }

  .rating-info-trigger {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    font-size: 11px;
  }

  .rating-info-popover {
    position: fixed;
    top: 58px;
    left: 2vw;
    right: 2vw;
    width: auto;
    max-height: 72vh;
    padding: 10px;
  }

  .rating-info-table {
    font-size: 11px;
  }

  .rating-info-table th,
  .rating-info-table td {
    padding: 4px 5px;
  }

  .rating-info-formula {
    font-size: 11px;
  }
}
