/**
 * Quiniela Liga MX - Leaderboard
 * Estilos de la tabla de posiciones y tabs
 */

/* ===== LEADERBOARD ===== */
.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-light);
  padding: 0.5rem;
  border-radius: var(--radius);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--primary-color);
  color: white;
}

.tab-btn:hover:not(.active) {
  background: rgba(0, 104, 71, 0.1);
  color: var(--primary-color);
}

.leaderboard-container {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

/* ===== LEADERBOARD TABLE ===== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-top: 1.5rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.95rem;
}

/* Table Header */
.leaderboard-table thead {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.leaderboard-table th {
  padding: 1rem 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 3px solid var(--primary-dark);
  white-space: nowrap;
}

.leaderboard-table th:nth-child(2) {
  text-align: left;
}

/* Table Body */
.leaderboard-table tbody tr {
  border-bottom: 1px solid #e5e7eb;
  transition: var(--transition);
}

.leaderboard-table tbody tr:last-child {
  border-bottom: none;
}

.leaderboard-table tbody tr:hover {
  background: linear-gradient(90deg, #f0fdf4 0%, #f9fafb 100%);
  transform: scale(1.01);
  box-shadow: 0 2px 4px rgba(54, 169, 67, 0.1);
}

.leaderboard-table td {
  padding: 1rem 0.75rem;
  color: var(--text-dark);
  vertical-align: middle;
}

/* Position Column */
.leaderboard-table td.position {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* Top 3 positions with special styling */
.leaderboard-table tbody tr:nth-child(1) td.position {
  color: #fbbf24;
  font-size: 1.3rem;
  text-shadow: 0 1px 2px rgba(251, 191, 36, 0.3);
}

.leaderboard-table tbody tr:nth-child(2) td.position {
  color: #94a3b8;
  font-size: 1.2rem;
  text-shadow: 0 1px 2px rgba(148, 163, 184, 0.3);
}

.leaderboard-table tbody tr:nth-child(3) td.position {
  color: #cd7f32;
  font-size: 1.15rem;
  text-shadow: 0 1px 2px rgba(205, 127, 50, 0.3);
}

/* User Info Column */
.leaderboard-table td:nth-child(2) {
  text-align: left;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.username {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.95rem;
}

/* Badge Perfect */
.badge-perfect {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
  white-space: nowrap;
}

/* Points Column */
.leaderboard-table td.points {
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary-color);
}

.leaderboard-table td.points strong {
  color: var(--primary-color);
}

/* Stats Column (Aciertos) */
.leaderboard-table td.stats {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Accuracy Column */
.leaderboard-table td.accuracy {
  text-align: center;
  color: var(--text-dark);
  font-weight: 600;
}

/* Current User Row */
.current-user {
  background: linear-gradient(90deg, #dbeafe 0%, #e0f2fe 100%);
}

.current-user:hover {
  background: linear-gradient(90deg, #bfdbfe 0%, #dbeafe 100%);
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}

.current-user .username {
  color: #1e40af;
  font-weight: 700;
}

.current-user td:last-child {
  color: #1e40af;
  font-size: 1.2rem;
}

/* Perfect Week Row */
.perfect-week {
  background: linear-gradient(90deg, #fef3c7 0%, #fef9c3 100%);
}

.perfect-week:hover {
  background: linear-gradient(90deg, #fde68a 0%, #fef3c7 100%);
  box-shadow: 0 4px 6px rgba(245, 158, 11, 0.2);
}

/* Combine both current-user and perfect-week */
.current-user.perfect-week {
  background: linear-gradient(90deg, #fef3c7 0%, #dbeafe 50%, #fef9c3 100%);
}

/* ===== BREAKDOWN TABLE (Games vs Series) ===== */
.leaderboard-table.with-breakdown {
  font-size: 0.9rem;
}

.breakdown-header {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.breakdown-cell {
  text-align: center;
  padding: 0.75rem 0.5rem;
}

.breakdown-points {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.breakdown-detail {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== PLAYOFF PHASES TABLE ===== */
.leaderboard-table.playoff-phases .phase-col,
.leaderboard-table.playoff-phases .total-col {
  text-align: center;
  font-weight: 600;
}

.leaderboard-table.playoff-phases .phase-col {
  color: var(--text-dark);
  font-size: 1rem;
}

.leaderboard-table.playoff-phases .total-col {
  color: var(--primary-color);
  font-size: 1.1rem;
}

.leaderboard-table.playoff-phases .total-col strong {
  color: var(--primary-color);
}

/* Champion bonus highlight */
.leaderboard-table.playoff-phases .champion-bonus {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #f59e0b;
  font-weight: 700;
}

/* Desktop Alignment Fix */
@media (min-width: 769px) {
  .leaderboard-table th:first-child,
  .leaderboard-table td:first-child {
    width: 80px;
    text-align: center;
  }

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

  .leaderboard-table th:nth-child(4),
  .leaderboard-table td:nth-child(4) {
    width: 140px;
  }

  .leaderboard-table th:last-child,
  .leaderboard-table td:last-child {
    width: 120px;
  }
}

/* ===== WEEK NAVIGATOR ===== */
.week-navigator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-lg);
}

.week-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
}

.week-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.week-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.week-nav-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  min-width: 180px;
  text-align: center;
}

.week-nav-label.active-week {
  position: relative;
}

.week-nav-label.active-week::after {
  content: '(Actual)';
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 0.25rem;
}

/* ===== WINNERS VIEW ===== */
.winners-view h2 {
  margin-bottom: 0;
}

.winners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.winner-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 1rem;
  transition: var(--transition);
}

.winner-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.winner-card.playoff-winner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
}

.winner-week {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 104, 71, 0.2);
}

.playoff-winner .winner-week {
  color: #b45309;
  border-bottom-color: rgba(180, 83, 9, 0.2);
}

.winner-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.winner-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.winner-medal {
  font-size: 1.2rem;
}

.winner-points {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-top: 0.25rem;
}

.playoff-winner .winner-points {
  color: #b45309;
}

.tied-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .leaderboard-container {
    padding: 0.75rem;
    border-radius: 0;
    box-shadow: none;
  }

  .table-responsive {
    margin-top: 1rem;
    border-radius: 0;
  }

  .leaderboard-table {
    font-size: 0.875rem;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.75rem 0.5rem;
  }

  .leaderboard-table td.position {
    font-size: 1rem;
  }

  .leaderboard-table tbody tr:nth-child(1) td.position {
    font-size: 1.2rem;
  }

  .leaderboard-table tbody tr:nth-child(2) td.position {
    font-size: 1.1rem;
  }

  .leaderboard-table tbody tr:nth-child(3) td.position {
    font-size: 1.05rem;
  }

  .username {
    font-size: 0.9rem;
  }

  .badge-perfect {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }

  .leaderboard-table td.points {
    font-size: 1rem;
  }

  .leaderboard-table td.stats,
  .leaderboard-table td.accuracy {
    font-size: 0.85rem;
  }

  /* Breakdown columns in mobile */
  .breakdown-cell {
    padding: 0.5rem 0.3rem;
  }

  .breakdown-points {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
  }

  .breakdown-detail {
    font-size: 0.7rem;
  }

  .breakdown-header {
    font-size: 0.75rem;
  }

  /* Week Navigator Mobile */
  .week-navigator {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .week-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .week-nav-label {
    font-size: 1rem;
    min-width: 140px;
  }

  .week-nav-label.active-week::after {
    font-size: 0.65rem;
  }

  /* Winners Grid Mobile */
  .winners-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .winner-card {
    padding: 0.75rem;
  }

  .winner-week {
    font-size: 0.8rem;
  }

  .winner-points {
    font-size: 1.1rem;
  }
}

/* ===== WINNERS TABLE ===== */
.winner-names {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.winner-entry {
  font-weight: 600;
  color: var(--text-dark);
}

.week-cell {
  font-weight: 600;
  color: var(--primary-color);
  white-space: nowrap;
}

.playoff-row {
  background: linear-gradient(90deg, #fef3c7 0%, #fef9c3 100%);
}

.playoff-row:hover {
  background: linear-gradient(90deg, #fde68a 0%, #fef3c7 100%);
}

.playoff-row .week-cell {
  color: #b45309;
}

.playoff-row .points strong {
  color: #b45309;
}

/* Winners table tied badge inline */
.winner-names .tied-badge {
  margin-top: 0;
  margin-left: 0.25rem;
}
