/* =========================================================
   CLASIFICACIONES – styles (FUSIÓN)
   Base principal: estilo NUEVO
   Toques recuperados del antiguo: glass/blur, sticky, selects,
   alternancia suave y contenedor con scroll.
========================================================= */

:root{
  --ab-green: #8BC34A;
  --ab-green-dark: #6FA62E;

  --ab-bg: #ffffff;
  --ab-text: rgba(0,0,0,.88);
  --ab-muted: rgba(0,0,0,.60);

  --ab-border: rgba(0,0,0,.10);
  --ab-border-strong: rgba(0,0,0,.16);

  --ab-shadow: 0 10px 30px rgba(0,0,0,.08);
  --ab-radius: 14px;

  --ab-glass: rgba(255,255,255,.82);
  --ab-glass-head: rgba(255,255,255,.92);

  --ab-focus: rgba(148,192,69,.65);
  --ab-focus-ring: rgba(148,192,69,.12);
}

/* ---------------------------------------------------------
   CONTENEDOR PRINCIPAL (glass del antiguo + estructura nueva)
--------------------------------------------------------- */
.viewer-card{
  background: var(--ab-glass);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(0,0,0,.08);
  overflow: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---------------------------------------------------------
   CABECERA (glass + compacto)
--------------------------------------------------------- */
.classif-head{
  background: var(--ab-glass-head);
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding: 16px 16px 10px;
}

.head-row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.head-title{
  margin: 0;
  font-weight: 900;
  letter-spacing: .35px;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--ab-text);
  line-height: 1.2;
}

.head-controls{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ctrl-group{
  display:flex;
  align-items:center;
  gap: 10px;
}

/* ---------------------------------------------------------
   BOTONES (mezcla: sombras suaves del antiguo + tacto nuevo)
--------------------------------------------------------- */
.circle-btn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.20);
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 24px rgba(0,0,0,.06);
  color: rgba(0,0,0,.85);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.circle-btn:hover{
  background: rgba(255,255,255,1);
  border-color: rgba(0,0,0,.28);
  box-shadow: 0 12px 28px rgba(0,0,0,.08);
}
.circle-btn:active{ transform: scale(.98); }
.circle-btn:disabled{
  opacity: .45;
  cursor: not-allowed;
}

/* ---------------------------------------------------------
   SELECTS (con flecha custom del antiguo, pero limpio)
--------------------------------------------------------- */
.form-control{
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(255,255,255,.95);
  box-shadow: none !important;
  height: 36px;
  font-weight: 800;
  font-size: 12px;
  color: rgba(0,0,0,.86);
}

.form-control:focus{
  border-color: var(--ab-focus);
  box-shadow: 0 0 0 4px var(--ab-focus-ring) !important;
}

/* Selects dentro de la cabecera: más premium */
.classif-head .form-control{
  height: 42px;
  padding: 10px 38px 10px 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .2px;
  border: 1px solid rgba(0,0,0,.22);
  background: rgba(255,255,255,.98);
  box-shadow: 0 8px 22px rgba(0,0,0,.06);
  transition: .12s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(0,0,0,.55) 50%),
    linear-gradient(135deg, rgba(0,0,0,.55) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

/* ---------------------------------------------------------
   TABS (más parecido al NUEVO, pero con subrayado del antiguo)
--------------------------------------------------------- */
.scope-tabs{
  display:flex;
  gap: 18px;
  margin-top: 10px;
  padding: 0 2px;
  border-bottom: 1px solid rgba(0,0,0,.10);
}
.scope-tabs input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.scope-tab{
  padding: 10px 2px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  color: rgba(0,0,0,.60);
  border-bottom: 2px solid transparent;
  transition: .12s ease;
}
.scope-tabs input:checked + .scope-tab{
  color: rgba(0,0,0,.92);
  border-bottom-color: #94c045;
}

/* Tipos: mezcla — look “pill” (nuevo) pero en grid (antiguo) */
.type-tabs{
  display:flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px 0 0;
  flex-wrap: wrap;
}
.type-tabs input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.type-tab{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.96);
  cursor: pointer;
  user-select: none;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  color: rgba(0,0,0,.78);
  transition: .12s ease;
  border-radius: 12px;
  min-width: 150px;
  flex: 1 1 auto;
  justify-content: center;
}
.type-tabs input:checked + .type-tab{
  background: rgba(148,192,69,.16);
  color: rgba(0,0,0,.92);
  border-color: rgba(148,192,69,.35);
}

.type-ico{
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(255,255,255,.98);
  font-weight: 900;
  font-size: 12px;
  line-height: 1;
}
.type-tabs input:checked + .type-tab .type-ico{
  border-color: rgba(148,192,69,.45);
  background: rgba(255,255,255,1);
}

/* ---------------------------------------------------------
   BODY / RESULTS (base nueva + scroll del antiguo)
--------------------------------------------------------- */
.classif-body{
  background: #fff;
  padding: 14px;
}

/* Contenedor con scroll controlado como el antiguo */
.results-wrap{
  border-top: 1px solid rgba(0,0,0,.06);
  max-height: calc(100vh - 260px);
  min-height: 650px;
  overflow: auto;

  border-radius: 12px;
}

/* ====== MODOS (mantiene tu lógica de columnas) ====== */
/* Normal: SOLO TIEMPO (Gap oculto) */
.results-wrap.mode-normal .r-head,
.results-wrap.mode-normal .r-row{
  grid-template-columns: 52px 1.2fr 1.2fr 0.9fr;
}
/* Puntos: SOLO PUNTOS */
.results-wrap.mode-points .r-head,
.results-wrap.mode-points .r-row{
  grid-template-columns: 52px 1.2fr 1.2fr 0.8fr;
}

/* ---------------------------------------------------------
   CABECERA DE COLUMNAS (sticky del antiguo, estética fusion)
--------------------------------------------------------- */
.r-head{
  position: sticky;
  top: 0;
  z-index: 6;

  display:grid;
  gap: 12px;
  padding: 10px 12px;

  background: rgba(255,255,255,.98);
  border-bottom: 1px solid rgba(0,0,0,.10);

  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .45px;
  color: #94c045;
}
.r-head div{ white-space: nowrap; }
.r-head .rh-right{ text-align:right; }

/* ---------------------------------------------------------
   FILAS (cards redondeadas del nuevo + alternancia suave)
--------------------------------------------------------- */
#resultsRows{
  display:flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0 0;
}

.r-row{
  display:grid;
  gap: 12px;
  align-items:center;

  padding: 14px 12px;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.04);
}

/* Alternancia suave (sin perder el look “card”) */
#resultsRows .r-row:nth-child(even){
  background: rgba(0,0,0,.02);
}

/* POS */
.r-rank{
  width: 38px;
  height: 38px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  border-radius: 10px;
  background: rgba(0,0,0,.92);
  color: #fff;
}

/* Nombre */
.r-name{
  font-weight: 950;
  letter-spacing: .2px;
  text-transform: uppercase;
  font-size: 13px;
  color: rgba(0,0,0,.88);
}
.muted{
  display:block;
  margin-top: 2px;
  opacity:.72;
  font-size: 12px;
  color: rgba(0,0,0,.55);
}

/* Equipo */
.r-team{
  font-weight: 850;
  font-size: 12px;
  text-transform: uppercase;
  opacity:.9;
  color: rgba(0,0,0,.78);
}

/* Tiempo / Puntos */
.r-time, .r-pts{
  font-weight: 950;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  color: rgba(0,0,0,.88);
}
.r-pts{ opacity:.85; }

/* Vacío / Loading */
.r-empty{
  padding: 22px 14px;
  border: 1px dashed rgba(0,0,0,.18);
  border-radius: 10px;
  background: rgba(0,0,0,.02);
  color: rgba(0,0,0,.70);
  font-weight: 800;
  text-align:center;
}
.r-loading{
  padding: 16px;
  text-align:center;
  font-weight: 900;
  opacity:.75;
  color: rgba(0,0,0,.70);
}

/* ---------------------------------------------------------
   SECCIÓN (recorrido) para Montaña/Sprints en ETAPA
   (sticky como el antiguo, con look nuevo)
--------------------------------------------------------- */
.r-section{
  position: sticky;
  top: 44px; /* deja visible la cabecera .r-head */
  z-index: 5;

  padding: 10px 12px;
  border-radius: 12px;

  background: rgba(148,192,69,.14);
  border: 1px solid rgba(148,192,69,.28);

  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .25px;
  font-size: 12px;
  color: rgba(0,0,0,.85);
}

/* ---------------------------------------------------------
   TOP 1 (compatibilidad: antiguo .r-top1 y nuevo .is-leader)
--------------------------------------------------------- */
/* Antiguo */
.r-top1 .r-row{
  background: #94c045 !important;
  border-color: rgba(0,0,0,.08);
  color: #fff;
}
.r-top1 .r-row .muted{ color: rgba(255,255,255,.85); }
.r-top1 .r-row .r-rank{
  background: #fff;
  color: #94c045;
}

/* Nuevo */
.r-row.is-leader{
  background: #94c045 !important;
  border-color: rgba(0,0,0,.08);
}
.r-row.is-leader .r-name,
.r-row.is-leader .r-team,
.r-row.is-leader .r-time,
.r-row.is-leader .r-pts,
.r-row.is-leader .muted{
  color: #fff !important;
}
.r-row.is-leader .muted{ opacity: .90; }
.r-row.is-leader .r-rank{
  background: #fff;
  color: #94c045;
}

/* ---------------------------------------------------------
   RESPONSIVE (móvil): mantener lo MEJOR del nuevo
   - head apilado
   - tabs con scroll horizontal
   - filas en 2 líneas
--------------------------------------------------------- */
@media (max-width: 991.98px){

  /* En móvil/tablet: 1 fila visual con columna central apilada */
  .results-wrap.mode-normal .r-head,
  .results-wrap.mode-normal .r-row,
  .results-wrap.mode-points .r-head,
  .results-wrap.mode-points .r-row{
    grid-template-columns: 52px 1fr 92px !important;
    grid-template-rows: auto auto !important;
    gap: 2px 10px !important;
    align-items: center;
  }

  /* ===== HEADER (POS / CORREDOR / EQUIPO / TIEMPO-PUNTOS) ===== */
  .r-head > :nth-child(1){
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }
  .r-head > :nth-child(2){
    grid-column: 2;
    grid-row: 1;
  }
  .r-head > :nth-child(3){
    grid-column: 2;
    grid-row: 2;
    opacity: .75;
    font-size: 10px;
  }
  .r-head > :nth-child(4){
    grid-column: 3;
    grid-row: 1 / span 2;
    justify-self: end;
    white-space: nowrap;
  }

  /* ===== ROWS ===== */
  .r-row .r-rank{
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  /* Contenedor del nombre + muted (2º hijo de .r-row) */
  .r-row > :nth-child(2){
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  /* Equipo debajo (3º hijo) */
  .r-row .r-team{
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Tiempo o puntos a la derecha (4º hijo) */
  .r-row .r-time,
  .r-row .r-pts{
    grid-column: 3;
    grid-row: 1 / span 2;
    justify-self: end;
    align-self: center;
    white-space: nowrap;
  }
}
@media (max-width: 575.98px){

  .results-wrap.mode-normal .r-head,
  .results-wrap.mode-normal .r-row,
  .results-wrap.mode-points .r-head,
  .results-wrap.mode-points .r-row{
    grid-template-columns: 44px 1fr 84px !important;
  }

  /* Cabecera un poco más compacta */
  .classif-head{
    padding: 12px 12px 8px 12px;
  }
  .head-controls{ justify-content: flex-start; }

  /* Selects y botones compactos */
  .circle-btn{
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .classif-head .form-control{
    height: 36px;
    padding: 8px 34px 8px 10px;
    font-size: 13px;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    background-position:
      calc(100% - 16px) 15px,
      calc(100% - 10px) 15px;
  }

  /* Tabs en una fila con scroll (nuevo) para ahorrar altura */
  .scope-tabs,
  .type-tabs{
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    gap: 8px;
    padding-bottom: 4px;
  }

  .type-tab{
    min-width: auto;
    flex: 0 0 auto;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .type-ico{
    width: 20px;
    height: 20px;
    border-radius: 7px;
  }

  /* Resultados: un pelín menos altos */
  .r-row{
    padding: 12px 10px;
  }
  .r-name{ font-size: 13px; }
  .r-team{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* El contenedor scroll: ajusta altura en móvil */
  .results-wrap{
    max-height: calc(100vh - 240px);
    min-height: 520px;
  }
}