/* ============================================================
   smgr · css/pages/cuatro_factores.css — CUATRO FACTORES
   Shell de UI (skin "Foco") sobre el endpoint AJAX compartido.
   Tabla ancha sticky con cabecera agrupada (Ofensivos/Defensivos),
   coloreado top-3/bottom-3 por columna y tarjeta comparativa de
   partido. Tokens en css/tokens.css; base en css/rincon.css.
   ============================================================ */

/* ---------- Cabecera de página (misma que avanzadas) ---------- */
.adv-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin-top: var(--sp-5); flex-wrap: wrap;
}
.adv-head h1 {
  font-family: var(--score); font-size: 26px; font-weight: 700;
  letter-spacing: .01em; color: var(--ink);
}
.adv-head .sub { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) { .adv-head h1 { font-size: 22px; } }

/* ---------- Enlace a avanzadas de equipos ---------- */
.cf-links { margin-top: var(--sp-3); }
.cf-link { font-size: 13px; font-weight: 600; color: var(--accent-deep); }
.cf-link:hover { text-decoration: underline; }

/* ---------- Conmutador de vistas (usa .tabs de rincon.css) ---------- */
.tabs { margin-top: var(--sp-4); }

/* ---------- Barra de filtros ---------- */
.cf-filters {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: var(--sp-4); padding: var(--sp-4); margin-top: var(--sp-4);
}
.cf-filters .fgroup { display: flex; flex-direction: column; gap: 6px; }
.cf-filters .flabel {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.cf-filters select {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background-color: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-input); padding: 6px 32px 6px 12px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235B6577' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.cf-filters select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cf-filters .btn { padding: 7px 16px; font-size: 13px; }
@media (max-width: 640px) {
  .cf-filters { gap: var(--sp-3); }
  .cf-filters .fgroup, .cf-filters select, .cf-filters .btn { width: 100%; }
}

/* ---------- Estados de carga / vacío ---------- */
.cf-loading, .cf-empty {
  margin-top: var(--sp-4); padding: var(--sp-4);
  text-align: center; font-size: 14px; color: var(--muted);
}

/* ---------- Tabla de factores ---------- */
.cf-section { margin-top: var(--sp-4); }
.cf-wrap {
  position: relative; overflow: auto; max-height: 78vh;
  border-radius: var(--r-card); transition: opacity .15s ease;
}
.cf-table { min-width: 860px; }

/* Cabecera agrupada de dos filas: ambas pegajosas en vertical.
   La fila de grupos arriba (top:0) y la fila de factores debajo (offset). */
.cf-table thead th { z-index: 3; }
.cf-table thead tr.cf-hgroup th { top: 0; }
.cf-table thead tr.cf-hsub th { top: 33px; }
.cf-table thead th { text-align: center; }
.cf-table th.r { text-align: right; }

/* Cabeceras de grupo Ofensivos / Defensivos */
.cf-table th.cf-off { background: #16513c; }   /* verde profundo sobre --ink */
.cf-table th.cf-def { background: #7a2a22; }   /* rojo profundo sobre --ink */

/* Primera columna (Equipo) sticky horizontal + esquina superior izquierda */
.cf-table th.stick-1, .cf-table td.stick-1 {
  position: sticky; left: 0; min-width: 150px; max-width: 170px;
  text-align: left;
  box-shadow: 4px 0 8px -4px rgba(19, 28, 46, .14);
}
.cf-table th.stick-1 { z-index: 5; top: 0; background: var(--ink); }
.cf-table td.stick-1 { background: var(--surface); z-index: 2; }
.cf-table tbody tr:nth-child(even) td.stick-1 { background: var(--zebra); }
.cf-table tbody tr:hover td.stick-1 { background: var(--hover); }
.cf-table td.stick-1 .team-tag { color: var(--ink); font-weight: 600; }
.cf-table td.stick-1 .team-tag:hover { color: var(--accent-deep); }

/* Tinte suave de las columnas ofensivas / defensivas en el cuerpo */
.cf-table td.cf-off { background: rgba(18, 128, 92, .05); }
.cf-table td.cf-def { background: rgba(192, 58, 46, .05); }

/* Diferencia de puntos coloreada */
.cf-table td.cf-diff-up { color: var(--up); font-weight: 700; }
.cf-table td.cf-diff-down { color: var(--down); font-weight: 700; }

/* Top-3 (verde) / bottom-3 (rojo) por columna — mismos tintes que las viz */
.cf-table td.cf-top3 { background: rgba(5, 150, 105, 0.2) !important; font-weight: 700; }
.cf-table td.cf-bot3 { background: rgba(220, 80, 80, 0.18) !important; font-weight: 700; }

/* Afordancia de orden en cabecera (además del hover de rincon.css) */
.cf-table th[data-col] { cursor: pointer; user-select: none; }
.cf-table th[data-col]:hover { color: var(--accent); }
.cf-table th[data-col][aria-sort="ascending"]::after { content: "\25B2"; font-size: 8px; margin-left: 4px; color: var(--accent); }
.cf-table th[data-col][aria-sort="descending"]::after { content: "\25BC"; font-size: 8px; margin-left: 4px; color: var(--accent); }

@media (max-width: 640px) {
  .cf-table { font-size: 12px; }
  .cf-table th, .cf-table td { padding: 6px 7px; }
  .cf-table thead tr.cf-hsub th { top: 29px; }
  .cf-table th.stick-1, .cf-table td.stick-1 { min-width: 132px; }
}

/* ---------- Tarjeta comparativa de partido ---------- */
.cf-match-card-wrap { max-width: 620px; margin: var(--sp-4) auto 0; }
.cf-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.cf-card-head {
  background: var(--ink); color: #fff;
  padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.cf-team-side { display: flex; align-items: center; gap: 10px; }
.cf-team-side--right { justify-content: flex-end; }
.cf-team-name {
  font-family: var(--score); font-weight: 700; font-size: 18px; color: #fff;
}
.cf-team-name:hover { color: var(--accent); text-decoration: none; }
.cf-score {
  font-family: var(--score); font-size: 28px; font-weight: 700; opacity: .55;
}
.cf-team-side.is-win .cf-score { opacity: 1; color: var(--accent); }
.cf-vs { font-size: 13px; opacity: .6; font-weight: 500; }

.cf-comparison { width: 100%; border-collapse: collapse; }
.cf-comparison thead th {
  padding: 10px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--muted); border-bottom: 1px solid var(--line); background: var(--ground);
}
.cf-comparison tbody td { padding: 13px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.cf-cmp-label { font-weight: 700; color: var(--muted); font-size: 13px; width: 110px; }
.cf-cmp-val { font-family: var(--score); font-size: 18px; font-weight: 600; color: var(--ink); }
.cf-cmp-val.cf-better { color: var(--up); font-weight: 700; }

@media (max-width: 640px) {
  .cf-card-head { flex-direction: column; gap: 8px; text-align: center; }
  .cf-team-side, .cf-team-side--right { justify-content: center; }
  .cf-team-name { font-size: 15px; }
  .cf-score { font-size: 22px; }
}

/* ---------- Definiciones (disclosure nativo, look de avanzadas) ---------- */
.adv-defs {
  margin-top: var(--sp-5); border: 1px solid var(--line);
  border-radius: var(--r-card); background: var(--surface);
}
.adv-defs > summary {
  cursor: pointer; padding: var(--sp-3) var(--sp-4);
  font-weight: 600; font-size: 14px; color: var(--ink); list-style: none;
}
.adv-defs > summary::-webkit-details-marker { display: none; }
.adv-defs > summary::before { content: '\25B8'; color: var(--accent-deep); margin-right: 8px; }
.adv-defs[open] > summary::before { content: '\25BE'; }
.adv-defs > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cf-defs__intro {
  padding: 0 var(--sp-4) var(--sp-3); margin: 0;
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.adv-defs__grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3) var(--sp-4); padding: 0 var(--sp-4) var(--sp-4);
}
@media (max-width: 700px) { .adv-defs__grid { grid-template-columns: 1fr; } }
.adv-defs__item { display: grid; grid-template-columns: 92px 1fr; gap: var(--sp-3); align-items: baseline; }
.adv-defs__term { font-weight: 700; color: var(--accent-deep); font-size: 13px; }
.adv-defs__item--def .adv-defs__term { color: var(--down); }
.adv-defs__desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.adv-defs__desc code {
  background: var(--ground); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 4px; font-size: 12px; color: var(--ink);
}
@media (max-width: 640px) {
  .adv-defs__item { grid-template-columns: 1fr; gap: 2px; }
}
