/* ==========================================================================
   1. RESET Y CONFIGURACIÓN BASE
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  background-color: #121316;
  color: #e1e3e6;
  min-height: 100vh;
}

/* ==========================================================================
   2. BANNERS PUBLICITARIOS
   ========================================================================== */
.top-ad-banner,
.top-ad-container {
  width: 100%;
  max-width: 1400px;
  margin: 10px auto;
  display: flex;
  justify-content: center;
  text-align: center;
}

.ad-placeholder {
  width: 728px;
  height: 90px;
  background-color: #1c1e22;
  border: 1px dashed #34383f;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #717782;
  font-size: 0.85rem;
}

.sidebar-ads-column {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}

.ad-banner-box,
.ad-placeholder-vertical {
  background-color: #1e293b;
  border: 1px dashed #334155;
  border-radius: 8px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  padding: 20px;
  width: 100%;
}

.ad-banner-box.vertical-tall,
.ad-placeholder-vertical {
  min-height: 520px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.ad-banner-box.vertical-short {
  min-height: 250px;
}

/* ==========================================================================
   3. NAVBAR Y ENCABEZADOS
   ========================================================================== */
.navbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.logo {
  font-size: 1.3rem;
  font-weight: bold;
}

.logo span {
  color: #ffffff;
}

.user-status {
  font-size: 0.85rem;
  color: #9ea4b0;
}

/* ==========================================================================
   4A. LAYOUT ESPECÍFICO PARA INDEX.HTML (PÁGINA PRINCIPAL)
   ========================================================================== */
.index-page .main-layout {
  display: grid;
  grid-template-columns: 340px 580px 340px;
  gap: 15px;
  max-width: 1300px;
  margin: 15px auto;
  justify-content: center;
  align-items: start;
}

.index-page .content-center {
  min-width: 0;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.index-page #matches-list {
  width: 100%;
  margin: 0 auto;
}

.index-page .sidebar-left,
.index-page .sidebar-right {
  width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   4B. LAYOUT ESPECÍFICO PARA PARTIDO.HTML (DETALLE Y FIXTURE AMPLIO)
   ========================================================================== */
.match-detail-page .main-layout {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 20px;
  max-width: 1480px;
  margin: 15px auto;
  justify-content: center;
  align-items: start;
}

.match-detail-page .content-center {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.match-detail-page .sidebar-left {
  width: 240px;
}

.match-detail-page .sidebar-right {
  width: 260px;
}

.match-detail-page #bracket-wrapper {
  transform: scale(0.68);
  transform-origin: top center;
}

/* ==========================================================================
   5. PANELES Y CAJAS LATERALES COMUNES
   ========================================================================== */
.sidebar-left {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.panel-box,
.sidebar-box,
.ad-banner-box {
  width: 100%;
  box-sizing: border-box;
}

.panel-box h3,
.sidebar-box h3 {
  font-size: 0.95rem;
  color: #9ea4b0;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.league-list,
#league-selector {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.league-list li,
#league-selector li,
#league-selector div {
  width: 100%;
  box-sizing: border-box;
}

.league-list li {
  padding: 8px 10px;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
}

.league-list li.active,
.league-list li:hover {
  background-color: #2b2e35;
  color: #ffffff;
}

.sidebar-box button,
#btn-fixture-side,
.btn-fixture {
  display: none !important;
}

/* ==========================================================================
   6. CONTENEDOR DE CAMPEONATO Y BARRA DE PESTAÑAS
   ========================================================================== */
.championship-header {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px 8px 0 0;
  padding: 15px 20px;
  margin-bottom: 0;
}

.championship-title {
  color: #38bdf8;
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav-tabs-container,
.filter-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  border-bottom: 2px solid #334155;
  padding-bottom: 12px;
}

.tab-btn,
.filter-btn {
  background-color: #0f172a;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover,
.filter-btn:hover {
  color: #fff;
  border-color: #0284c7;
}

.tab-btn.active,
.filter-btn.active {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
}

.filter-btn.live-btn {
  color: #ff4d4d;
}

.league-header {
  background-color: #23262d;
  padding: 10px 15px;
  border-radius: 8px 8px 0 0;
  font-weight: bold;
  font-size: 0.9rem;
  border-bottom: 1px solid #2b2e35;
}

/* ==========================================================================
   7. FILAS DE PARTIDOS (PESTAÑA LISTA PARTIDOS)
   ========================================================================== */
.matches-container {
  background-color: #1c1e22;
  border-radius: 0 0 8px 8px;
}

.match-row {
  display: grid;
  grid-template-columns: 1fr 110px 1fr;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #23262d;
  gap: 8px;
  cursor: pointer;
}

.match-row:hover {
  background-color: #1e2229;
}

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

.team-local {
  justify-content: flex-end;
  text-align: right;
}

.team-visitor {
  justify-content: flex-start;
  text-align: left;
}

.team-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e1e3e6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-logo {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px;
  min-height: 20px;
  max-width: 20px !important;
  max-height: 20px !important;
  object-fit: contain;
  flex-shrink: 0;
  background-color: transparent;
}

.match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.match-time {
  font-size: 0.72rem;
  color: #8b929e;
  font-weight: bold;
  text-transform: uppercase;
}

.match-time.is-live {
  color: #ef4444;
}

.match-score-badge {
  background-color: #2b2e35;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.88rem;
  color: #ffffff;
  width: 100%;
  text-align: center;
}

.match-score-badge.live-score {
  background-color: #2563eb;
  color: #ffffff;
}

/* ==========================================================================
   8. TABLA DE POSICIONES (PESTAÑA TABLA)
   ========================================================================== */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  color: #f8fafc;
}

.custom-table th {
  background-color: #0f172a;
  color: #38bdf8;
  padding: 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  border-bottom: 2px solid #334155;
}

.custom-table td {
  padding: 10px;
  border-bottom: 1px solid #334155;
}

/* ==========================================================================
   9. FIXTURE EMBEBIDO EN LA PESTAÑA CENTRAL
   ========================================================================== */
.fixture-embed-wrapper {
  width: 100%;
  height: auto;
  max-width: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  background-color: #0d1117;
  border-radius: 0 0 8px 8px;
  padding: 15px 0;
  box-sizing: border-box;
}

.bracket-viewport-container {
  width: 100% !important;
  position: relative !important;
  box-sizing: border-box !important;
}

.fixture-embed-wrapper .bracket-wrapper {
  transform-origin: top center;
  margin: 0 auto;
}

/* ==========================================================================
   10. BARRA SUPERIOR DE DEPORTES
   ========================================================================== */
.sports-bar-container {
  max-width: 1400px;
  width: 100%;
  margin: 15px auto;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sports-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  scrollbar-width: thin;
}

.sport-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.sport-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sport-item.active {
  background-color: #1e293b;
  color: #38bdf8;
  border-color: #0284c7;
  font-weight: bold;
}

/* ==========================================================================
   11. ADAPTABILIDAD RESPONSIVA Y MÓVIL
   ========================================================================== */
@media (max-width: 1024px) {
  .index-page .main-layout,
  .match-detail-page .main-layout,
  .main-layout {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 10px !important;
    box-sizing: border-box !important;
    margin: 10px auto !important;
  }

  .sidebar-left, 
  .sidebar-right,
  .index-page .sidebar-left,
  .index-page .sidebar-right,
  .match-detail-page .sidebar-left,
  .match-detail-page .sidebar-right {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }

  .content-center,
  .index-page .content-center,
  .match-detail-page .content-center {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .ad-placeholder {
    width: 100% !important;
    height: 70px !important;
  }
}

/* AJUSTE AUTO DYNAMIC HEIGHT PARA LA TABLA DE POSICIONES EN ADMIN */
#contenedor-tablas-grupos .table-section-card {
  min-height: 0 !important;
  height: auto !important;
  padding: 15px 20px !important;
  margin-bottom: 15px !important;
}

#contenedor-tablas-grupos .table-responsive {
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
}

/* ==========================================================================
   12. AJUSTE RESPONSIVO PARA EL MARCADOR DE GOLES EN DETALLE
   ========================================================================== */
.score-badge-large {
  font-size: 1.8rem !important;
  padding: 8px 18px !important;
  white-space: nowrap !important;
  display: inline-block !important;
  letter-spacing: 1px !important;
}

@media (max-width: 480px) {
  .score-badge-large {
    font-size: 1.3rem !important;
    padding: 6px 12px !important;
  }

  .team-box-large span {
    font-size: 0.95rem !important;
  }

  .team-box-large img {
    width: 48px !important;
    height: 48px !important;
  }
}

/* ==========================================================================
   13. REGLAS ESTRUCTURALES PARA LA FILA DE PARTIDOS CENTRADA EN INDEX
   ========================================================================== */
#matches-list {
  width: 100% !important;
  box-sizing: border-box !important;
}

#matches-list > div {
  box-sizing: border-box !important;
}

#matches-list img {
  display: block !important;
  max-width: 22px !important;
  max-height: 22px !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
}

#matches-list span {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.matches-container > div {
  border-bottom: 1px solid #334155 !important;
}

.matches-container > div:last-child {
  border-bottom: none !important;
}

/* ==========================================================================
   14. PROTECCIÓN EXCLUSIVA MÓVIL (IPHONE / SMARTPHONES)
   ========================================================================== */
#matches-list span {
  font-size: 0.8rem !important;
}

@media (max-width: 480px) {
  #matches-list span {
    font-size: 0.75rem !important;
  }
  
  #matches-list div[style*="border: 1.5px solid"],
  #matches-list div[style*="border:1.5px solid"] {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}