/* ============================================================
   css/pages/calculadora_acb.css — Calculadora de Clasificación ACB (Foco).
   Cargado por head.php cuando la página define $page_css='calculadora_acb'.
   Reutiliza .card / .table / .btn / .team-tag / .shield / .breadcrumb / .section
   de rincon.css; aquí sólo lo específico del editor de "y si...".
   ============================================================ */

/* ---------- Cabecera de página + nav compañera ---------- */
.calc-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-3); margin-top: var(--sp-5); flex-wrap: wrap;
}
.calc-head h1 {
  font-family: var(--score); font-size: 30px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.1;
}
.calc-head__sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

/* Segmented compañero (Calculadora | Simulación) — .seg es page-scoped */
.calc-seg { display: inline-flex; }
.seg {
  display: inline-flex; background: var(--ground);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px;
}
.seg a {
  font-size: 12px; font-weight: 600; padding: 5px 12px;
  border-radius: var(--r-pill); color: var(--muted); white-space: nowrap;
}
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.is-active { background: var(--ink); color: #fff; }
.seg a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.calc-intro {
  font-size: 13.5px; color: var(--muted); margin-top: var(--sp-3);
  max-width: 760px; line-height: 1.5;
}

/* ---------- Controles ---------- */
.calc-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.calc-controls .btn { font-size: 13px; padding: 7px 16px; }
.save-feedback {
  display: inline-block; font-size: 12.5px; color: var(--up); font-weight: 600;
  opacity: 0; transition: opacity .3s;
}
.save-feedback.visible { opacity: 1; }
.save-feedback.is-error { color: var(--down); }
.calc-counter { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 500; }
.calc-counter strong { color: var(--ink); }

/* ---------- Rejilla juegos / clasificación ---------- */
.calc-grid { margin-top: var(--sp-4); }
.calc-games { min-width: 0; }
.calc-standings-wrap { margin-top: var(--sp-5); }

/* Escritorio: dos columnas con clasificación sticky (>=992px, evita romper flex móvil) */
@media (min-width: 992px) {
  .calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); align-items: start; }
  .calc-standings-wrap { margin-top: 0; position: sticky; top: calc(var(--header-h) + 8px); }
}

/* ---------- Grupos de jornada ---------- */
.jornada-group {
  margin-bottom: var(--sp-2);
  border: 1px solid var(--line); border-radius: var(--r-input);
  overflow: hidden; background: var(--surface);
}
.jornada-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 9px var(--sp-3);
  background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 700; cursor: pointer; text-align: left;
  border: 0; font-family: inherit;
}
.jornada-header:hover { background: var(--court-b); }
.jornada-badge {
  display: inline-block; background: rgba(255,255,255,.15);
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 500; margin-left: 8px;
}
.jornada-header .toggle-icon { display: inline-flex; transition: transform .2s; }
.jornada-header .toggle-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.jornada-header .toggle-icon.collapsed { transform: rotate(-90deg); }
.jornada-body.collapsed { display: none; }

/* ---------- Filas de partido ---------- */
.game-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px var(--sp-3); border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.game-row:last-child { border-bottom: none; }
.game-team {
  display: flex; align-items: center; gap: 5px; min-width: 0;
  cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px;
  transition: background .15s;
}
.game-team:hover { background: var(--accent-soft); }
.game-team.home { flex: 1; justify-content: flex-end; text-align: right; }
.game-team.away { flex: 1; justify-content: flex-start; }
.game-team .shield { flex-shrink: 0; }
.game-team-name {
  font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-team-name.short-name { display: none; }
.game-score-inputs { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.game-ida-inline {
  font-size: 10px; color: var(--muted); white-space: nowrap; flex-shrink: 0;
  width: 72px; text-align: right;
}
.game-ida-team { display: none; font-size: 9px; color: var(--muted); white-space: nowrap; }
.game-score-inputs input {
  width: 42px; height: 30px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-input);
  font-size: 13px; font-weight: 700; color: var(--ink); padding: 0;
  background: var(--surface); font-family: inherit;
}
.game-score-inputs input:focus {
  border-color: var(--ink); outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.game-score-inputs input.filled { background: var(--accent-soft); border-color: var(--accent); }
.game-score-sep { color: var(--muted); font-weight: 700; font-size: 14px; }
.game-row.won-home .game-team.home .game-team-name { color: var(--up); font-weight: 700; }
.game-row.won-away .game-team.away .game-team-name { color: var(--up); font-weight: 700; }

/* Partido en juego */
.game-row.is-live { background: linear-gradient(90deg, var(--down-tint) 0%, transparent 50%, var(--down-tint) 100%); }
.live-badge {
  display: inline-block; background: var(--down); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 3px;
  letter-spacing: .3px; margin-right: 4px; flex-shrink: 0;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .65; } }

/* ---------- Clasificación calculada ---------- */
.standings-card { overflow: hidden; }
.standings-title { flex: 1; }
.standings-table-wrap { overflow-x: auto; scrollbar-width: thin; }
.standings-table { font-size: 12.5px; }
.standings-table th { padding: 6px 8px; font-size: 10px; }
.standings-table td { padding: 6px 8px; text-align: center; vertical-align: middle; }
.standings-table td.r { text-align: right; }
.standings-table tbody tr { cursor: pointer; }
.standings-table .team-cell { text-align: left; }
.standings-table .team-tag { color: var(--ink); gap: 5px; }
.standings-table .team-tag:hover { color: var(--accent-deep); text-decoration: none; }
.standings-table .team-abbr { font-weight: 700; }
.standings-table .rank-cell { font-weight: 700; color: var(--muted); white-space: nowrap; text-align: center; }
.standings-table td.up { color: var(--up); font-weight: 600; }
.standings-table td.down { color: var(--down); font-weight: 600; }

/* Flechas de cambio de posición */
.rank-change { font-size: 9px; margin-left: 2px; font-weight: 700; }
.rank-change.up { color: var(--up); }
.rank-change.down { color: var(--down); }

/* Separadores de zona (corte de competición: 4 / 8 / descenso) */
.standings-table tr.zone-4 td { border-bottom: 2.5px solid var(--accent); }
.standings-table tr.zone-8 td { border-bottom: 2.5px solid var(--pos-b); }
.standings-table tr.zone-16 td { border-bottom: 2.5px solid var(--down); }

/* Botón de captura (en la card-bar oscura) */
.btn-screenshot {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  color: #fff; font-size: 12px; padding: 4px 11px; border-radius: var(--r-pill);
  cursor: pointer; font-weight: 600; transition: background .2s;
}
.btn-screenshot:hover { background: rgba(255,255,255,.28); }
.btn-screenshot:disabled { cursor: default; opacity: .8; }

/* Marca de agua (oculta hasta la captura) */
.standings-watermark {
  display: none; padding: 8px var(--sp-3);
  background: var(--ink); color: var(--muted-dark);
  font-size: 10px; text-align: center; border-top: 1px solid var(--line-dark);
}
.standings-watermark .wm-site { color: #fff; font-weight: 600; }
.standings-card.capturing .standings-watermark { display: block; }
.standings-card.capturing .btn-screenshot { display: none; }

/* ---------- Explorador de desempates ---------- */
.tb-section { padding: var(--sp-4) var(--sp-5); }
.tb-section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.tb-section-header h3 { font-family: var(--score); font-size: 18px; font-weight: 700; color: var(--ink); }
.tb-section-subtitle { font-size: 12px; color: var(--muted); margin-bottom: var(--sp-3); }
.tb-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0 12px; border-bottom: 1px dashed var(--line); margin-bottom: var(--sp-3);
}
.tb-label { font-size: 12px; font-weight: 600; color: var(--ink); }
.tb-selected { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-empty-chips { font-size: 12px; color: var(--muted); font-style: italic; }
.tb-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 6px; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; color: var(--accent-deep); line-height: 1;
}
.tb-chip .shield { width: 16px; height: 16px; }
.tb-chip button {
  background: rgba(240,162,60,.28); border: none; color: var(--accent-deep);
  width: 16px; height: 16px; border-radius: 50%; font-size: 12px; line-height: 1;
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; margin-left: 1px;
}
.tb-chip button:hover { background: rgba(240,162,60,.5); }
.tb-add-select {
  padding: 6px 10px; font-size: 12px; border: 1px solid var(--line);
  border-radius: var(--r-input); background: var(--surface); color: var(--ink); max-width: 220px;
}
.tb-clear {
  font-size: 11px; padding: 5px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-pill); cursor: pointer;
  color: var(--muted); margin-left: auto;
}
.tb-clear:hover { background: var(--hover); color: var(--ink); }
.tb-hint { font-size: 12px; color: var(--muted); font-style: italic; padding: 12px 0; text-align: center; }
.tb-size-section { margin-bottom: var(--sp-4); }
.tb-size-section:last-child { margin-bottom: 0; }
.tb-size-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin-bottom: 6px;
}
.tb-rows.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px; }
.tb-rows.multi { display: flex; flex-direction: column; gap: 4px; }
.tb-row {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 10px; background: var(--ground); border-radius: var(--r-input);
  font-size: 12.5px; width: fit-content;
}
.tb-team-mini { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; color: var(--ink); }
.tb-team-mini .shield { width: 14px; height: 14px; }
.tb-team-code { font-weight: 700; }
.tb-stats {
  color: var(--muted); font-weight: 500; font-size: 10.5px;
  font-variant-numeric: tabular-nums; margin-left: 2px; white-space: nowrap;
}
.tb-stats .tb-wl { color: var(--muted); }
.tb-stats .tb-pd.pos { color: var(--up); font-weight: 600; }
.tb-stats .tb-pd.neg { color: var(--down); font-weight: 600; }
.tb-sep { font-weight: 700; font-size: 13px; margin: 0 4px; }
.tb-sep.gt { color: var(--ink); }
.tb-sep.q { color: var(--accent-deep); font-weight: 800; }

/* ---------- Modal de equipo ---------- */
.calc-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(19,28,46,.5); z-index: 9999;
  justify-content: center; align-items: flex-start;
  padding: 40px 16px; overflow-y: auto;
}
.calc-modal-overlay.active { display: flex; }
.calc-modal-box {
  background: var(--surface); border-radius: var(--r-card);
  max-width: 620px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-pop);
}
.calc-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; background: var(--court); color: #fff;
  border-radius: var(--r-card) var(--r-card) 0 0; position: relative;
}
.calc-modal-header .shield { width: 28px; height: 34px; }
.calc-modal-header .modal-team-name { font-size: 16px; font-weight: 700; }
.calc-modal-header .modal-team-record { font-size: 12px; opacity: .85; margin-left: auto; }
.calc-modal-header .modal-team-rank {
  background: rgba(255,255,255,.2); padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700;
}
.calc-modal-close {
  position: absolute; top: 10px; right: 14px; color: #fff; opacity: .7;
  font-size: 20px; cursor: pointer; background: none; border: none; padding: 0; line-height: 1;
}
.calc-modal-close:hover { opacity: 1; }
.calc-modal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.calc-modal-table thead th {
  background: var(--ink); color: #fff; padding: 6px 8px; text-align: center;
  font-size: 10px; font-weight: 700;
}
.calc-modal-table thead th.modal-th-rival { text-align: left; }
.calc-modal-table tbody td {
  padding: 5px 8px; text-align: center; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.calc-modal-table tbody tr:nth-child(even) { background: var(--zebra); }
.calc-modal-table .modal-team-cell { text-align: left; }
.modal-team-info { display: flex; align-items: center; gap: 4px; }
.modal-team-info .shield { width: 14px; height: 18px; }
.modal-team-info span { font-weight: 600; color: var(--ink); }
.ha-badge {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; text-transform: uppercase;
}
.ha-badge.home { background: var(--pos-b-tint); color: var(--pos-b); }
.ha-badge.away { background: var(--down-tint); color: var(--down); }
.calc-modal-played { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-modal-played.won { color: var(--up); }
.calc-modal-played.lost { color: var(--muted); }
.modal-score-inputs { display: flex; align-items: center; gap: 3px; justify-content: center; }
.modal-score-inputs input {
  width: 38px; height: 26px; text-align: center; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--ink);
  padding: 0; background: var(--surface); font-family: inherit;
}
.modal-score-inputs input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.modal-score-inputs input.filled { background: var(--accent-soft); border-color: var(--accent); }
.modal-score-sep { color: var(--muted); font-weight: 700; font-size: 12px; }
.calc-modal-tiebreakers {
  background: var(--ground); border-top: 1px solid var(--line);
  padding: 12px 16px; border-radius: 0 0 var(--r-card) var(--r-card);
}
.calc-modal-tiebreakers h4 { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--ink); }
.tb-no-ties { font-size: 12px; color: var(--muted); font-style: italic; }
.tb-mini-standings { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12px; }
.tb-mini-standings thead th { background: var(--ink); color: #fff; padding: 4px 6px; text-align: center; font-size: 10px; font-weight: 700; }
.tb-mini-standings thead th:nth-child(2) { text-align: left; padding-left: 8px; }
.tb-mini-standings tbody td {
  padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.tb-mini-standings tbody td:nth-child(2) { text-align: left; padding-left: 8px; font-weight: 600; }
.tb-mini-standings tbody tr.is-me td { background: var(--accent-soft); font-weight: 700; }
.tb-mini-standings .pd-pos { color: var(--up); font-weight: 600; }
.tb-mini-standings .pd-neg { color: var(--down); font-weight: 600; }
.tb-mini-standings .rank-cell { color: var(--muted); font-weight: 700; width: 28px; }
.tb-pair {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  font-size: 12px; border-bottom: 1px solid var(--line);
}
.tb-pair:last-child { border-bottom: none; }
.tb-pair .tb-teams { font-weight: 600; color: var(--ink); min-width: 80px; }
.tb-pair .tb-legs { font-weight: 400; color: var(--muted); }
.tb-pair .tb-legs.incomplete { color: var(--down); }
.tb-pair .tb-record { font-variant-numeric: tabular-nums; }
.tb-pair .tb-record-diff { color: var(--muted); }
.tb-pair .tb-diff { font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-pair .tb-advantage { color: var(--up); }
.tb-pair .tb-disadvantage { color: var(--down); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .calc-head { align-items: flex-start; flex-direction: column; }
  .calc-head h1 { font-size: 24px; }
  .game-team-name.full-name { display: none; }
  .game-team-name.short-name { display: inline; }
  .game-score-inputs input { width: 38px; height: 28px; font-size: 12px; }
  .game-ida-inline { display: none; }
  .game-ida-team { display: inline; }
  .game-row { padding: 6px 8px; }
  .calc-modal-overlay { padding: 20px 8px; }
  .calc-counter { margin-left: 0; width: 100%; }
}

/* ============================================================
   Aviso de carga al ir a la Simulación (Monte Carlo tarda)
   ============================================================ */
.calc-loading {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(19, 28, 46, .55); backdrop-filter: blur(2px);
}
.calc-loading__box {
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-card); padding: var(--sp-6) var(--sp-5);
  max-width: 340px; text-align: center;
  box-shadow: 0 18px 40px -18px rgba(19, 28, 46, .55);
}
.calc-loading__title { font-family: var(--score); font-size: 18px; font-weight: 700; margin-top: var(--sp-3); }
.calc-loading__sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.calc-spinner {
  display: inline-block; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: calc-spin .8s linear infinite;
}
@keyframes calc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .calc-spinner { animation-duration: 2.4s; }
}
