/* ============================= */
/*           VARIABLES           */
/* ============================= */

:root {
  --bg-main: #f4f6f8;
  --card-bg: #ffffff;
  --table-header: #e6e8eb;
  --text-main: #1f2937;

  --green-bg: #c8f1d1;
  --green-strong: #15803d;

  --red-bg: #f6c7c7;
  --red-strong: #b91c1c;

  --row-hover: #eef2f7;
}

/* ============================= */
/*            GENERAL            */
/* ============================= */

body {
  font-family: "Inter", "Segoe UI", sans-serif;
  background-image: url("../../../frontend/bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  margin: 0;
  padding: 30px;
}

.page {
  max-width: 1400px;
  margin: auto;
}

.card {
  background: #ffffff;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  color: #111827; /* 👈 Texto oscuro dentro de la card */
}

.title,
h3,
h4 {
  color: #111827;
}

/* ============================= */
/*            HEADER             */
/* ============================= */

.headerRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.title {
  font-size: 22px;
  font-weight: 700;
}

.filters {
  display: flex;
  gap: 20px;
}

.filterBlock {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================= */
/*           SUMMARY             */
/* ============================= */

.summary {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
}

.summaryBox {
  flex: 1;
  background: #f3f4f6;
  padding: 15px;
  border-radius: 10px;
  font-size: 14px;
}

.summaryBox strong {
  display: block;
  font-size: 22px;
  margin-top: 5px;
}

/* ============================= */
/*           MAIN GRID           */
/* ============================= */

.mainLayout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
}

.leaders h3,
.matchups h3 {
  margin-top: 0;
}

.matchups h4 {
  margin-bottom: 8px;
  margin-top: 20px;
}

/* ============================= */
/*            TABLE              */
/* ============================= */

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  overflow: visible;
}

thead {
  background: var(--table-header);
}

th {
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  padding: 12px;
}

td {
  text-align: center;
  padding: 14px 10px;
  font-size: 14px;
  border-bottom: 1px solid #ececec;
}

td img {
  width: 55px;
  border-radius: 6px;
}

.leaderZoom {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.leaderZoomPreview {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px) scale(.96);
  opacity: 0;
  pointer-events: none;
  z-index: 120;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.35);
  background: rgba(2,6,23,.92);
  box-shadow: 0 20px 38px rgba(2,6,23,.40);
  padding: 6px;
  transition: opacity .14s ease, transform .14s ease;
}

.leaderZoomPreview img {
  width: 170px;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  border: 0;
  background: rgba(2,6,23,.35);
}

.leaderZoom:hover .leaderZoomPreview {
  opacity: 1;
  transform: translateY(-50%) translateX(0) scale(1);
}

td:nth-child(2) {
  text-align: left;
  font-weight: 500;
  padding-left: 12px;
}

/* ============================= */
/*         HOVER EFFECT          */
/* ============================= */

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: var(--row-hover);
}

/* ============================= */
/*      WR / COLOR SYSTEM        */
/* ============================= */

.wr-positive {
  background: var(--green-bg);
  color: var(--green-strong);
  font-weight: 700;
}

.wr-negative {
  background: var(--red-bg);
  color: var(--red-strong);
  font-weight: 700;
}

/* ============================= */
/*         LEADER VIEW           */
/* ============================= */

#leaderSummary {
  display: flex;
  align-items: flex-start;
  gap: 50px;
  margin-bottom: 50px;
}


.leaderImage {
  width: 140px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.leaderSummaryStats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
  width: 100%;
  max-width: 900px;
}

.leaderSummaryStats div {
  background: #f3f4f6;
  padding: 22px 10px;
  border-radius: 16px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.leaderSummaryStats strong {
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
  font-weight: 800;
}

/* Números más grandes en tablas */
.leaders td:not(:nth-child(1)):not(:nth-child(2)),
.matchups td:not(:first-child) {
  font-size: 16px;
  font-weight: 600;
}

/* Compactar tablas de matchups */
.matchups table td {
  padding: 8px 6px;
}

.matchups table th {
  padding: 8px 6px;
  font-size: 13px;
}

.matchups h4:first-of-type + table {
  background: #f0fbf4;
  border: 1px solid #c8f1d1;
}

.matchups h4:last-of-type + table {
  background: #fff1f1;
  border: 1px solid #f6c7c7;
}

.matchups td:nth-child(2),
.matchups td:nth-child(3) {
  font-size: 17px;
  font-weight: 700;
}

/* Matchup leader columna */
.matchupLeader {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.matchupLeader img {
  width: 40px;
  border-radius: 6px;
}

/* Keep zoom preview size consistent; do not inherit tiny matchup thumb size */
.matchupLeader .leaderZoomPreview img {
  width: 170px;
  max-height: 260px;
}

.matchupLeader span {
  font-size: 13px;
  font-weight: 500;
}

/* Alinear tabla derecha a la izquierda */
.matchups td,
.matchups th {
  text-align: left;
}

.matchups td:nth-child(n+2),
.matchups th:nth-child(n+2) {
  text-align: center;
}

/* Reducir padding aún más */
.matchups table td {
  padding: 6px 6px;
}

.matchups table th {
  padding: 6px 6px;
}

/* ============================= */
/*        HEADER UPGRADE         */
/* ============================= */

.headerRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.title {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.filters {
  display: flex;
  gap: 25px;
  align-items: center;
}

.filterBlock {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

/* Selects modernos */
select {
  appearance: none;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

select:hover {
  background: #e5e7eb;
}

select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

#backToSummary {
  background: #0f172a;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 30px;
}

#backToSummary:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

/* WR card completa */
.leaderSummaryStats div.wr-positive {
  background: #c8f1d1;
  color: #065f46;
}

.leaderSummaryStats div.wr-negative {
  background: #f6c7c7;
  color: #7f1d1d;
}

.miniMatchup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.miniMatchup img {
  width: 50px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* Ensure zoom preview in Fav/Desf keeps full size (not 50px thumb size) */
.miniMatchup .leaderZoomPreview img {
  width: 170px;
  max-height: 260px;
  box-shadow: none;
}

.miniMatchup span {
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
}

.sync-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.sync-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.sync-btn-secondary {
  background: #0f172a;
}

.sync-btn-secondary:hover {
  background: #1e293b;
}

.sync-status {
  margin-top: 10px;
  font-weight: 600;
}

.sync-loading {
  color: #888;
}

.sync-success {
  color: #2ecc71;
}

.sync-info {
  color: #3498db;
}

.sync-error {
  color: #e74c3c;
}

.teamSummaryWrap {
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 16px;
  background:
    radial-gradient(520px 180px at 6% 0%, rgba(124,58,237,.16), transparent 75%),
    radial-gradient(520px 180px at 100% 0%, rgba(6,182,212,.13), transparent 75%),
    linear-gradient(160deg, rgba(15,23,42,.90), rgba(30,41,59,.76));
  color: #e2e8f0;
  padding: 12px;
  margin-bottom: 18px;
}

.teamSummaryWrap h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(241,245,249,.94);
}

.teamSummaryBody {
  display: grid;
  gap: 12px;
  overflow: visible;
}

.teamHighlight {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(15,23,42,.24);
}

.teamHighlightTop {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(226,232,240,.76);
  margin-bottom: 6px;
}

.teamHighlightName {
  margin: 0;
  font-size: 24px;
  font-weight: 1000;
  color: #fff;
}

.teamHighlightSub {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(226,232,240,.82);
}

.teamKpis {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.teamKpi {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(15,23,42,.28);
  padding: 8px;
}

.teamKpiLabel {
  font-size: 11px;
  color: rgba(226,232,240,.70);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 900;
}

.teamKpiValue {
  font-size: 20px;
  font-weight: 1000;
  line-height: 1.15;
  color: #fff;
}

.teamRankWrap {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  overflow: visible;
  background: rgba(15,23,42,.24);
  position: relative;
  z-index: 1;
}

.teamRankTable {
  width: 100%;
  border-collapse: collapse;
  overflow: visible;
  min-width: 980px;
}

.teamRankTable thead {
  background: rgba(15,23,42,.42);
}

.teamRankTable th {
  font-size: 12px;
  color: rgba(226,232,240,.84);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 900;
}

.teamRankTable td {
  border-bottom: 1px solid rgba(255,255,255,.10);
  color: #f8fafc;
  overflow: visible;
  position: relative;
}

.teamRankTable td:first-child {
  text-align: center;
  padding-left: 10px;
  font-weight: 900;
}

.teamRankTable td:nth-child(2) {
  text-align: left;
  padding-left: 12px;
}

.teamRankTable tr:last-child td {
  border-bottom: 0;
}

.teamRankTable .rankPos {
  width: 34px;
  text-align: center;
  font-weight: 1000;
}

.teamRankTable .playerName {
  font-weight: 1000;
}

.teamRankTable .statStrong {
  font-weight: 1000;
}

.teamRankTable tr.rankRow td {
  transition: background .15s ease;
}

.teamRankTable tr.rank-1 td {
  background: linear-gradient(90deg, rgba(245,158,11,.24), rgba(250,204,21,.18));
}

.teamRankTable tr.rank-2 td {
  background: linear-gradient(90deg, rgba(148,163,184,.26), rgba(203,213,225,.18));
}

.teamRankTable tr.rank-3 td {
  background: linear-gradient(90deg, rgba(180,83,9,.22), rgba(251,146,60,.14));
}

.teamRankTable tr.rank-4 td,
.teamRankTable tr.rank-5 td,
.teamRankTable tr.rank-6 td,
.teamRankTable tr.rank-7 td,
.teamRankTable tr.rank-8 td,
.teamRankTable tr.rank-9 td,
.teamRankTable tr.rank-10 td {
  background: rgba(59,130,246,.10);
}

.teamLeaderCell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.teamLeaderZoom {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  z-index: 2;
}

.teamLeaderZoom:hover {
  z-index: 10000;
}

.teamLeaderCell img,
.leaderMiniFallback {
  width: 42px;
  height: 58px;
  border-radius: 6px;
  border: 1px solid rgba(15,23,42,.18);
  object-fit: contain;
  background: #fff;
}

.teamLeaderZoomPreview {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px) scale(.96);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.35);
  background: rgba(15,23,42,.92);
  box-shadow: 0 20px 38px rgba(2,6,23,.40);
  padding: 6px;
  transition: opacity .14s ease, transform .14s ease;
}

.teamLeaderZoomPreview img {
  width: 180px;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  display:block;
  border-radius: 8px;
  border: 0;
  background: rgba(2,6,23,.35);
}

.teamLeaderZoom:hover .teamLeaderZoomPreview {
  opacity: 1;
  transform: translateY(-50%) translateX(0) scale(1);
}

.leaderMiniFallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.teamLeaderCell span {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  line-height: 1.15;
}

@media (max-width: 760px) {
  .leaderZoomPreview {
    display: none !important;
  }

  .teamLeaderCell img,
  .leaderMiniFallback {
    width: 36px;
    height: 50px;
  }

  .teamLeaderZoomPreview {
    display: none !important;
  }
}

.team-page .teamSummaryWrap {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(15,23,42,.14);
}

.team-page .teamSummaryWrap h3 {
  color: #0f172a;
}

.team-page .teamHighlight {
  background: #ffffff;
  border-color: rgba(15,23,42,.14);
}

.team-page .teamHighlightTop,
.team-page .teamHighlightSub {
  color: #334155;
}

.team-page .teamHighlightName,
.team-page .teamKpiValue {
  color: #0f172a;
}

.team-page .teamKpi {
  background: #f8fafc;
  border-color: rgba(15,23,42,.14);
}

.team-page .teamKpiLabel {
  color: #475569;
}

.team-page .teamRankWrap {
  background: #ffffff;
  border-color: rgba(15,23,42,.14);
  overflow: visible;
}

.team-page .teamRankTable thead {
  background: #e5e7eb;
}

.team-page .teamRankTable th,
.team-page .teamRankTable td {
  color: #0f172a;
}

.team-page .teamRankTable td {
  border-bottom: 1px solid rgba(15,23,42,.10);
}

/* ============================= */
/*          RESPONSIVE           */
/* ============================= */

@media (max-width: 1024px) {
  .headerRow {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .filters {
    width: 100%;
    flex-wrap: wrap;
    gap: 12px;
  }

  .mainLayout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .teamKpis {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  body {
    padding: 0;
  }

  .title {
    font-size: 28px;
    line-height: 1;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .filterBlock {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .filterBlock select {
    width: 100%;
  }

  .sync-btn {
    width: 100%;
    justify-self: stretch;
  }

  .sync-status {
    margin-top: 2px;
  }

  .teamRankWrap,
  .team-page .teamRankWrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .teamRankTable {
    min-width: 760px;
  }

  .teamKpis {
    grid-template-columns: 1fr;
  }

  .teamHighlightName {
    font-size: 20px;
  }

  .teamHighlightSub {
    font-size: 11px;
  }

  .summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .summaryBox {
    padding: 12px;
    font-size: 13px;
  }

  .summaryBox strong {
    font-size: 24px;
    margin-top: 4px;
  }

  .leaders,
  .matchups,
  #leaderView {
    width: 100%;
    min-width: 0;
  }

  .leaders table,
  #leaderView table {
    min-width: 760px;
  }

  .matchups table {
    min-width: 360px;
  }

  .leaders,
  .matchups,
  #leaderView {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .leaders table,
  .matchups table,
  #leaderView table {
    border-radius: 10px;
  }

  #leaderSummary {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }

  .leaderSummaryStats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: none;
  }

  .leaderSummaryStats div {
    padding: 14px 8px;
    font-size: 13px;
  }

  .leaderSummaryStats strong {
    font-size: 22px;
    margin-bottom: 5px;
  }
}
