/* ============================================================
   Relatives & Rivals Extra — FPL Colour Theme
   ============================================================ */

:root {
  --fpl-purple: #37003c;
  --fpl-purple-mid: #5a1060;
  --fpl-green: #00ff87;
  --fpl-cyan: #04f5ff;
  --fpl-white: #ffffff;
  --fpl-light: #f4f4f4;
  --fpl-red: #e90052;
  --fpl-grey: #6c757d;
  --gw-high-bg: #00ff8722;
  --gw-high-text: #005a2e;
  --gw-low-bg: #e9005222;
  --gw-low-text: #7a0029;
}

/* ---- Base ---- */
body {
  background-color: var(--fpl-light);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: #1a1a2e;
}

/* ---- Navbar ---- */
.fpl-navbar {
  background-color: var(--fpl-purple);
  border-bottom: 3px solid var(--fpl-green);
}

.fpl-navbar .navbar-brand {
  color: var(--fpl-white);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.fpl-navbar .navbar-brand span {
  color: var(--fpl-green);
}

.fpl-navbar .nav-link {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  transition: color 0.15s;
}

.fpl-navbar .nav-link:hover,
.fpl-navbar .nav-link.active {
  color: var(--fpl-green);
}

/* ---- Page header ---- */
.fpl-page-header {
  background: linear-gradient(135deg, var(--fpl-purple) 0%, var(--fpl-purple-mid) 100%);
  color: var(--fpl-white);
  padding: 2rem 0 1.5rem;
  margin-bottom: 2rem;
}

.fpl-page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.fpl-page-header .subtitle {
  color: var(--fpl-green);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---- GW Points Table ---- */
.gw-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(55, 0, 60, 0.12);
}

.fpl-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  background: var(--fpl-white);
  font-size: 0.875rem;
}

.fpl-table thead th {
  background-color: var(--fpl-purple);
  color: var(--fpl-white);
  font-weight: 700;
  text-align: center;
  padding: 0.65rem 0.6rem;
  white-space: nowrap;
  border: none;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Sticky left columns */
.fpl-table thead th:nth-child(1),
.fpl-table thead th:nth-child(2),
.fpl-table thead th:nth-child(3) {
  position: sticky;
  left: 0;
  z-index: 3;
  background-color: var(--fpl-purple);
}

.fpl-table thead th:nth-child(2) { left: 40px; }
.fpl-table thead th:nth-child(3) { left: 180px; }

.fpl-table tbody td {
  text-align: center;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #e8e8f0;
  white-space: nowrap;
}

/* Sticky left data cells */
.fpl-table tbody td:nth-child(1),
.fpl-table tbody td:nth-child(2),
.fpl-table tbody td:nth-child(3) {
  position: sticky;
  background-color: var(--fpl-white);
  z-index: 1;
  font-weight: 600;
}

.fpl-table tbody td:nth-child(1) { left: 0; width: 40px; }
.fpl-table tbody td:nth-child(2) { left: 40px; width: 140px; text-align: left; }
.fpl-table tbody td:nth-child(3) { left: 180px; width: 130px; text-align: left; }

/* Row hover */
.fpl-table tbody tr:hover td {
  background-color: #f0fff8;
}

.fpl-table tbody tr:hover td:nth-child(1),
.fpl-table tbody tr:hover td:nth-child(2),
.fpl-table tbody tr:hover td:nth-child(3) {
  background-color: #f0fff8;
}

/* GW high / low highlights */
.gw-high {
  background-color: var(--gw-high-bg) !important;
  color: var(--gw-high-text);
  font-weight: 700;
}

.gw-low {
  background-color: var(--gw-low-bg) !important;
  color: var(--gw-low-text);
  font-weight: 700;
}

.gw-avg-above { background-color: #dbeafe !important; color: #1e40af; }
.gw-avg-below { background-color: #fef3c7 !important; color: #92400e; }

/* Total column */
.col-total {
  background-color: #f8f0ff;
  font-weight: 700;
  color: var(--fpl-purple);
  border-left: 2px solid var(--fpl-purple);
}

thead .col-total {
  background-color: var(--fpl-green) !important;
  color: var(--fpl-purple) !important;
}

/* Rank badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  background-color: var(--fpl-purple);
  color: var(--fpl-white);
}

.rank-badge.rank-gold   { background: #FFD700; color: #5a3a00; font-size: 0.9rem; }
.rank-badge.rank-silver { background: #C0C0C0; color: #333;    font-size: 0.9rem; }
.rank-badge.rank-bronze { background: #CD7F32; color: #fff;    font-size: 0.9rem; }

/* ---- Footer ---- */
.fpl-footer {
  background-color: var(--fpl-purple);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  padding: 1rem 0;
  margin-top: 3rem;
  text-align: center;
}

.fpl-footer .last-refreshed {
  color: var(--fpl-green);
  font-weight: 600;
}

/* Shown when a refresh was started but never completed, or failed outright. */
.fpl-footer .refresh-warn {
  color: var(--fpl-red);
  font-weight: 600;
}

/* ---- Alerts ---- */
.fpl-alert {
  background-color: #fff3cd;
  border-left: 4px solid #ffc107;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* ---- Section headings ---- */
.fpl-section-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fpl-purple);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- Chip badges ---- */
.gw-cell {
  position: relative;
}

.chip-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.5rem;
  font-weight: 800;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  cursor: default;
}

.chip-tc,
.chip-bb,
.chip-fh,
.chip-wc { background: var(--fpl-purple); color: #fff; }

/* ---- Mobile: hide team name column, tighten manager sticky column ---- */
@media (max-width: 767px) {
  .fpl-table th.col-team,
  .fpl-table td.col-team { display: none; }
  .fpl-table thead th:nth-child(3) { left: 40px; }
  .fpl-table tbody td:nth-child(3) { left: 40px; width: 90px; }
}

/* ---- Team value chart + breakdown modal (Feature 2) ---- */
.value-mode-btn {
  border: 1px solid var(--fpl-purple);
  background: transparent;
  color: var(--fpl-purple);
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 20px;
  cursor: pointer;
  line-height: 1.6;
}

.value-mode-btn.active {
  background: var(--fpl-purple);
  color: var(--fpl-white);
}

.tv-hint {
  font-size: 0.72rem;
  color: var(--fpl-grey);
}

.tv-sub {
  font-size: 0.8rem;
  color: var(--fpl-grey);
  margin-top: 2px;
}

.tv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #ececec;
  font-size: 0.88rem;
}

.tv-figs {
  color: var(--fpl-grey);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tv-figs em {
  font-style: normal;
  font-weight: 700;
  margin-left: 8px;
}

.tv-up   { color: var(--gw-high-text); }
.tv-down { color: var(--gw-low-text); }
.tv-flat { color: var(--fpl-grey); }

.tv-dim { opacity: 0.6; }

.tv-net {
  border-bottom: none;
  border-top: 2px solid var(--fpl-purple);
  margin-top: 4px;
  padding-top: 9px;
  font-weight: 700;
}

.tv-note {
  font-size: 0.8rem;
  color: var(--fpl-grey);
  margin-bottom: 10px;
}

.tv-foot {
  margin-top: 12px;
  margin-bottom: 0;
}

.tv-moves {
  border-bottom: 1px solid #ececec;
  font-size: 0.8rem;
  line-height: 1.6;
}

/* Pill legend for the team value chart: the pill IS the manager colour */
.tv-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.tv-legend-pill {
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 12px;
  line-height: 1.6;
  cursor: pointer;
}

.tv-legend-pill.off {
  background: transparent;
  font-weight: 400;
  opacity: 0.55;
}

/* ---- Squad comparison (Feature 3) ---- */
.sc-gw {
  border: 1px solid var(--fpl-purple);
  color: var(--fpl-purple);
  background: transparent;
  border-radius: 20px;
  font-size: 0.72rem;
  padding: 2px 10px;
  line-height: 1.6;
  cursor: pointer;
}

.sc-sub-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--fpl-purple);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.sc-caption {
  font-size: 0.75rem;
  color: var(--fpl-grey);
  margin: 6px 0 0;
}

.sc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.sc-card {
  background: var(--fpl-white);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sc-card-k {
  font-size: 0.7rem;
  color: var(--fpl-grey);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sc-card-v {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fpl-purple);
}

/* The grid scrolls sideways on narrow screens, same as the GW table */
.sc-matrix-wrap {
  overflow-x: auto;
  background: var(--fpl-white);
  border-radius: 8px;
  padding: 10px;
}

.sc-table {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.72rem;
}

.sc-table th {
  font-weight: 400;
  color: var(--fpl-grey);
  padding: 2px;
}

.sc-row-h {
  text-align: right;
  padding-right: 8px !important;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--fpl-white);
}

.sc-corner {
  position: sticky;
  left: 0;
  background: var(--fpl-white);
}

.sc-cell {
  width: 34px;
  height: 27px;
  text-align: center;
  border-radius: 4px;
  font-weight: 700;
}

.sc-cell[data-a] {
  cursor: pointer;
}

.sc-cell[data-a]:hover,
.sc-cell[data-a]:focus {
  outline: 2px solid var(--fpl-green);
  outline-offset: -2px;
}

.sc-self {
  background: transparent;
  color: #ccc;
  font-weight: 400;
}

.sc-own {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #ececec;
  font-size: 0.82rem;
}

.sc-own-name em {
  font-style: normal;
  font-size: 0.7rem;
  color: var(--fpl-grey);
  margin-left: 6px;
}

.sc-own-fig {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.sc-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--fpl-purple);
  display: inline-block;
}

.sc-own-n {
  font-size: 0.75rem;
  color: var(--fpl-grey);
  min-width: 58px;
  text-align: right;
}

/* Pair modal */
.sc-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.sc-col h4 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--fpl-grey);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.sc-col h4 span {
  color: var(--fpl-purple);
}

.sc-p {
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid #ececec;
}

.sc-p em {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  color: var(--fpl-grey);
}

.sc-both h4 span {
  color: var(--gw-high-text);
}

.sc-capt {
  font-weight: 700;
}

.sc-c {
  display: inline-block;
  background: var(--fpl-purple);
  color: var(--fpl-white);
  border-radius: 3px;
  font-size: 0.6rem;
  padding: 0 4px;
  vertical-align: 1px;
}

@media (max-width: 575px) {
  .sc-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── IF... the league were mountains (fixed snapshot) ──────────────────── */
.mtn-dots { color: var(--fpl-green); -webkit-text-stroke: 0.5px var(--fpl-purple); }

.mtn-panel {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  padding: 16px 8px 8px;
  overflow-x: auto;
}
/* Twelve peaks need the width; below this the panel scrolls sideways, the
   same way the gameweek table does. */
.mtn-panel svg { min-width: 1000px; }

.mtn-panel text { text-anchor: middle; }
.mtn-elev { font-size: 11px; font-weight: 700; fill: #888; }
.mtn-mgr  { font-size: 13px; font-weight: 800; fill: var(--fpl-purple); }
.mtn-name { font-size: 12px; font-weight: 700; }
.mtn-meta { font-size: 10px; fill: #777; }
