/* Palette taken from the Samply admin template (primary #0576b9). Light is the
   default; the dark override kicks in on [data-theme="dark"] (set before paint
   by an inline script, so there's no flash). */
:root {
  color-scheme: light;
  --brand: #0576b9;
  --brand-hover: #046aa6;
  --bg: #f3f3f9;
  --card: #ffffff;
  --border: #e7e9f1;
  --track: #e7e9f1;
  --text: #495057;
  --muted: #9599ad;
  --heading: #343a40;
  --prog-line: #0576b9;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1420;
  --card: #161c2b;
  --border: #232c40;
  --track: #232c40;
  --text: #e6e9ef;
  --muted: #9aa4b8;
  --heading: #eef1f7;
  --prog-line: #4aa8e0;
}

/* Bootstrap form controls follow the theme in dark mode. */
:root[data-theme='dark'] .form-select,
:root[data-theme='dark'] .form-control {
  background-color: #0f1420;
  color: var(--text);
  border-color: var(--border);
}
:root[data-theme='dark'] .form-control::placeholder {
  color: var(--muted);
}
:root[data-theme='dark'] .alert-secondary {
  background-color: var(--card);
  color: var(--text);
  border-color: var(--border);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

.topbar {
  background: var(--brand);
  color: #fff;
}

.card-cat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 0.1rem 0.35rem rgba(18, 38, 63, 0.06);
}

.card-cat .cat-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
}

/* Connection indicator, sitting on the blue topbar. */
.live-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
  background: rgba(255, 255, 255, 0.45);
}
.live-dot.on {
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  }
  70% {
    box-shadow: 0 0 0 0.5rem rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

/* Currently-performing choreography. */
.turno-row.activo {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: rgba(5, 118, 185, 0.06);
  border-radius: 0.5rem;
}

.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.hora-chip {
  width: 3rem;
  flex: 0 0 auto;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Resultados: position + score chips. */
.pos-chip {
  width: 2rem;
  flex: 0 0 auto;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}
.score-chip {
  flex: 0 0 auto;
  min-width: 3.5rem;
  text-align: right;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
:root[data-theme='dark'] .score-chip {
  color: #4aa8e0;
}

/* "Ver detalle" badge (soft-info style from the template) — links to the
   external score summary. */
.badge-detalle {
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(5, 118, 185, 0.12);
  border: 1px solid rgba(5, 118, 185, 0.25);
}
.badge-detalle:hover {
  background: rgba(5, 118, 185, 0.2);
}

/* Programa schedule table — theme-aware (Bootstrap table vars). */
.prog-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  color: var(--text);
}
.prog-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}
.prog-table td,
.prog-table th {
  border-color: var(--border);
}
.prog-table .hora-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.prog-table .no-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}
/* Category advance as a thin fill along the row's bottom edge — subtle, one per
   row, never a saturated column. `--pct` is set inline per row. */
.prog-row {
  background: linear-gradient(90deg, var(--prog-line) var(--pct, 0%), var(--track) var(--pct, 0%))
    left bottom / 100% 2px no-repeat;
}

/* Currently-performing row in flat tables (minuto v3). */
.prog-table tr.fila-activa td {
  background: rgba(5, 118, 185, 0.08);
  font-weight: 600;
}
:root[data-theme='dark'] .prog-table tr.fila-activa td {
  background: rgba(74, 168, 224, 0.12);
}

/* Landing page: event cards. */
.group-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
}
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}
.event-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 0.1rem 0.35rem rgba(18, 38, 63, 0.06);
  transition:
    transform 0.12s ease,
    border-color 0.12s ease;
}
.event-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}
.event-poster {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--track);
}
.event-poster img {
  position: relative; /* paints over .poster-fallback */
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* No poster (or a broken one): a neutral tile with the event initial. */
.event-poster.sin-poster img {
  display: none;
}
.poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #0a4d78);
}
.event-live {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.event-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.event-name {
  font-weight: 600;
  line-height: 1.25;
}
.event-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-variant-numeric: tabular-nums;
}

/* Stats strip (competidores). */
.stats-row {
  display: flex;
  flex-wrap: wrap;
}
.stats-row .stat {
  flex: 1 1 33%;
  min-width: 120px;
  text-align: center;
  padding: 0.25rem 0.5rem;
  border-right: 1px solid var(--border);
}
.stats-row .stat:last-child {
  border-right: none;
}
.stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
:root[data-theme='dark'] .stat-num {
  color: #6cc0f0;
}
.stat-lbl {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Pager. */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.pg {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 0.35rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
}
.pg:disabled {
  opacity: 0.45;
  cursor: default;
}
.pg.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

@media print {
  .topbar,
  .nav-bar,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card-cat {
    border: none;
    box-shadow: none;
  }
}

/* Rhythm tabs (medallero). */
.ritmo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.ritmo-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}
.ritmo-tab:hover {
  border-color: var(--brand);
}
.ritmo-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* Medal table. */
.medal-table .medal-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.medal-table tr.top-medal td {
  background: rgba(5, 118, 185, 0.05);
}
.medal-table tr.top-medal .no-cell {
  color: var(--brand);
}
:root[data-theme='dark'] .medal-table tr.top-medal td {
  background: rgba(74, 168, 224, 0.08);
}
:root[data-theme='dark'] .medal-table tr.top-medal .no-cell {
  color: #6cc0f0;
}
:root[data-theme='dark'] .badge-detalle {
  color: #6cc0f0;
  background: rgba(74, 168, 224, 0.16);
  border-color: rgba(74, 168, 224, 0.3);
}

/* Podium (top 3) — gold / silver / bronze, arranged 2-1-3 on wide screens. */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
}
.podium-card {
  flex: 1 1 30%;
  min-width: 150px;
  max-width: 230px;
  text-align: center;
  padding: 1rem 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-top-width: 4px;
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: 0 0.2rem 0.7rem rgba(18, 38, 63, 0.1);
}
.medal-ico {
  width: 1.35rem;
  height: 1.35rem;
  vertical-align: middle;
}
.medal-ico-lg {
  display: block;
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
}
.podium-card.p1 .medal-ico-lg {
  width: 2.4rem;
  height: 2.4rem;
}
.podium-avatar {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  object-fit: cover;
  margin: 0.4rem auto 0.3rem;
  border: 3px solid var(--border);
  background: var(--border);
}
.podium-pos {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.podium-name {
  font-weight: 700;
  margin-top: 0.15rem;
}
.podium-acad {
  font-size: 0.78rem;
  color: var(--muted);
}
.podium-score {
  margin-top: 0.4rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--brand);
}
:root[data-theme='dark'] .podium-score {
  color: #4aa8e0;
}

.podium-card.p1 {
  border-top-color: #f5c518;
}
.podium-card.p2 {
  border-top-color: #b7c0cd;
}
.podium-card.p3 {
  border-top-color: #cd8b45;
}
.podium-card.p1 .podium-avatar {
  border-color: #f5c518;
  width: 5.5rem;
  height: 5.5rem;
}
.podium-card.p2 .podium-avatar {
  border-color: #b7c0cd;
}
.podium-card.p3 .podium-avatar {
  border-color: #cd8b45;
}

@media (min-width: 576px) {
  .podium-card.p1 {
    order: 2;
    transform: translateY(-0.7rem);
  }
  .podium-card.p2 {
    order: 1;
  }
  .podium-card.p3 {
    order: 3;
  }
}
@media (max-width: 575.98px) {
  .podium-card {
    flex-basis: 100%;
    max-width: none;
  }
}

/* Status badges — template palette, no green. */
.badge-estatus {
  font-weight: 600;
}
.badge-activo {
  background: var(--brand);
  color: #fff;
}
.badge-fin {
  background: #adb5bd;
  color: #fff;
}
.badge-pres {
  background: #3fb0e6;
  color: #fff;
}
.badge-espera {
  background: #eef2f7;
  color: #495057;
}

.viewers {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  border-radius: 0.3rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
.icon-btn svg {
  display: block;
}

/* Navigation bar under the top bar. Scrolls horizontally on small screens so a
   day with many links never wraps into a saturated block. */
.nav-bar {
  display: flex;
  gap: 0.1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.nav-link-x {
  padding: 0.6rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav-link-x:hover {
  color: var(--text);
}
.nav-link-x.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
:root[data-theme='dark'] .nav-link-x.active {
  color: #6cc0f0;
  border-bottom-color: #6cc0f0;
}

.lang-switch {
  display: inline-flex;
  gap: 0.15rem;
}
.lang-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  border-radius: 0.3rem;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
}
.lang-btn.active {
  background: #fff;
  color: var(--brand);
  font-weight: 700;
}

.theme-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  border-radius: 0.3rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Progress bars in template blue. */
.progress {
  background-color: var(--track);
  border-radius: 999px;
}
.progress-bar {
  background-color: var(--brand);
}
.progress-dia {
  height: 0.6rem;
}
.progress-cat {
  height: 0.35rem;
}

.btn-top {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0.4rem 1rem rgba(18, 38, 63, 0.25);
  cursor: pointer;
  z-index: 1030;
}
.btn-top:hover {
  background: var(--brand-hover);
}

@media (max-width: 575.98px) {
  .desktop-only {
    display: none !important;
  }
}
@media (min-width: 576px) {
  .mobile-only {
    display: none !important;
  }
}
