/* ==========================================================================
   QuiniGold Club — Módulo: Centro de Ligas Oficiales (Fase 2)
   Tablas de Posiciones en Vivo y Top Goleadores (Pichichis)
   Mobile-First, Glassmorphism, Accesible y Alto Contraste
   ========================================================================== */

/* Overlay del Modal */
.league-center-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

/* Tarjeta Contenedora Principal */
.league-center-card {
  background: var(--color-bg-card, #111827);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-xl, 20px);
  width: min(840px, calc(100vw - 2rem));
  max-width: 840px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
  padding: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
}

@media (max-width: 640px) {
  .league-center-card {
    max-height: 94vh;
    border-radius: 16px;
  }
}

/* Cabecera Fija y Congelada (Sticky Header Shell) */
.league-center-sticky-header {
  background: #111827;
  padding: 18px 20px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

@media (max-width: 640px) {
  .league-center-sticky-header {
    padding: 14px 14px 12px 14px;
    gap: 10px;
  }
}

/* Barra Superior de Utilidad */
.league-center-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.league-center-title {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--font-display, inherit);
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.league-center-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.league-center-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
  transform: scale(1.05);
}

/* Fila de Selector Desplegable Prominente (Visible en Móvil <640px, Oculto en PC) */
.league-selector-row {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
}

@media (max-width: 639px) {
  .league-selector-row {
    display: flex;
  }
}

.league-select-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.league-select-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  pointer-events: none;
  z-index: 2;
}

.league-select-dropdown {
  width: 100%;
  background: #1e293b;
  color: #f8fafc;
  border: 1.5px solid rgba(245, 158, 11, 0.5);
  border-radius: 10px;
  padding: 10px 38px 10px 48px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.league-select-flag-preview {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.league-select-dropdown:hover,
.league-select-dropdown:focus {
  border-color: var(--color-gold, #f59e0b);
  outline: none;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}

.league-select-dropdown option {
  background: #0f172a;
  color: #ffffff;
  padding: 10px;
  font-size: 13.5px;
}

/* Selector Horizontal de Competiciones (Visible en PC ≥640px, Oculto en Móvil) */
.league-selector-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

@media (max-width: 639px) {
  .league-selector-strip {
    display: none !important;
  }
}

.league-selector-strip::-webkit-scrollbar {
  height: 4px;
}

.league-selector-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.league-chip-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.league-chip-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.12);
  vertical-align: middle;
  flex-shrink: 0;
  display: inline-block;
}

.league-chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.league-chip-btn.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.15) 100%);
  border-color: var(--color-gold, #f59e0b);
  color: var(--color-gold, #f59e0b);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
  font-weight: 800;
}

/* Segmented Control para Alternar Vistas: Tabla vs Goleadores */
.league-view-tabs {
  display: flex;
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  gap: 6px;
  box-sizing: border-box;
}

.league-tab-btn {
  flex: 1 1 50%;
  width: 50%;
  max-width: 50%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  min-height: 40px;
}

.league-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.league-tab-btn.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.15) 100%);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fde68a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  font-weight: 800;
}

/* Cuerpo con Scroll Independiente */
.league-center-scrollable-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

@media (max-width: 640px) {
  .league-center-scrollable-body {
    padding: 12px 12px 20px 12px;
    gap: 12px;
  }
}

/* Meta-info de la Competición Activa */
.league-hero-header {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.league-hero-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.league-emblem-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.league-hero-name {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
}

.league-hero-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ==========================================================================
   TABLA DE CLASIFICACIÓN (STANDINGS TABLE)
   ========================================================================== */
.league-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.4);
}

.league-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: center;
  min-width: 580px;
}

.league-table th {
  background: rgba(30, 41, 59, 0.8);
  color: #94a3b8;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.league-table td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  vertical-align: middle;
}

.league-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.league-table tr:last-child td {
  border-bottom: none;
}

/* Columna de Posición y Zonas */
.col-pos {
  width: 38px;
  font-weight: 800;
  position: relative;
}

.pos-pill {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

/* Indicadores de Zonas Deportivas */
.row-zone-champions td:first-child .pos-pill {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.row-zone-europa td:first-child .pos-pill {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.row-zone-descenso td:first-child .pos-pill {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Columna de Equipo */
.col-team {
  text-align: left;
  padding-left: 10px !important;
}

.league-team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #ffffff;
}

.league-team-crest {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Columna de Puntos */
.col-pts {
  font-weight: 900;
  color: var(--color-gold, #f59e0b) !important;
  font-size: 13px;
  background: rgba(245, 158, 11, 0.04);
}

/* Columna de Forma Reciente */
.col-form {
  min-width: 105px;
}

.league-form-wrap {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.league-form-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.league-form-v { background: #10b981; }
.league-form-e { background: #f59e0b; }
.league-form-d { background: #ef4444; }

/* Leyenda de Zonas */
.league-table-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #94a3b8;
  padding: 8px 4px 0 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot-champions { background: #3b82f6; }
.legend-dot-europa { background: #f59e0b; }
.legend-dot-descenso { background: #ef4444; }

/* ==========================================================================
   TABLA DE GOLEADORES (TOP SCORERS / PICHICHIS)
   ========================================================================== */
.league-scorers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.league-scorer-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.15s ease;
}

.league-scorer-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.scorer-rank-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  flex-shrink: 0;
  line-height: 1;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

.scorer-rank-1 {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(217, 119, 6, 0.2) 100%);
  border: 1px solid var(--color-gold, #f59e0b);
  color: var(--color-gold, #f59e0b);
}

.scorer-rank-2 {
  background: rgba(203, 213, 225, 0.2);
  border: 1px solid #cbd5e1;
  color: #f1f5f9;
}

.scorer-rank-3 {
  background: rgba(180, 83, 9, 0.2);
  border: 1px solid #b45309;
  color: #d97706;
}

.scorer-info-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.scorer-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scorer-team {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.scorer-team-crest {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

.scorer-team-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.scorer-team-country {
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.7;
  font-size: 10.5px;
}

.scorer-stats-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.scorer-goals-pill {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 46px;
  flex-shrink: 0;
}

.scorer-extra-stats {
  font-size: 10.5px;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  white-space: nowrap;
}

/* Spinner y Estado de Carga */
.league-loading-wrap {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #94a3b8;
  font-size: 13px;
}

.league-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-gold, #f59e0b);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
