/* ==========================================================================
   THEME.CSS — Sistema de apariencia global
   --------------------------------------------------------------------------
   Un único archivo CSS para toda la aplicación. Si necesitas un cambio visual
   que afecte a todas las páginas, se hace AQUÍ.

   Estructura:
     1. Tokens de diseño (tema claro y oscuro)
     2. Base / reset / tipografía
     3. Utilidades de accesibilidad (foco visible, selección)
     4. Animaciones compartidas
     5. Secciones por página (Login primero; se agregan al migrar cada página)

   Modo oscuro: html[data-theme="dark"] — se activa desde js/theme.js.
   ========================================================================== */

/* ==========================================================================
   1. TOKENS DE DISEÑO — TEMA CLARO
   ========================================================================== */
:root {
  color-scheme: light;

  /* Color de marca */
  --brand-1: #4e73df;            /* Azul principal */
  --brand-2: #764ba2;            /* Púrpura */
  --brand-3: #7c3aed;            /* Violeta de acento */
  --brand-1-soft: rgba(78, 115, 223, 0.12);
  --brand-2-soft: rgba(118, 75, 162, 0.12);
  --accent: #1cc88a;             /* Verde de éxito / puntos */
  --danger: #e74c3c;
  --warning: #f6c23e;

  /* Superficies y texto */
  --bg: #eef1f8;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-muted: #f4f6fb;
  --surface-raised: #ffffff;         /* modales, dropdowns, popups (elevación por sombra) */
  --surface-hover: #e7ebf4;          /* hover de filas, items y botones secundarios */
  --text: #101828;
  --text-muted: #667085;
  /* Énfasis bajo (etiquetas de acordeón). En claro coincide con --text-muted
     porque un gris más pálido no cumple contraste AA sobre las superficies. */
  --text-soft: #667085;
  --border: rgba(16, 24, 40, 0.10);
  --border-strong: rgba(16, 24, 40, 0.16);

  /* Tipografía */
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;

  /* Formas y sombras: multicapa + anillo sutil que define la tarjeta sobre el fondo */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 0 0 1px rgba(16, 24, 40, 0.03);
  --shadow-md: 0 2px 6px rgba(16, 24, 40, 0.05), 0 10px 24px rgba(16, 24, 40, 0.10), 0 0 0 1px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 20px rgba(16, 24, 40, 0.10), 0 28px 60px rgba(16, 24, 40, 0.16), 0 0 0 1px rgba(16, 24, 40, 0.05);
  --ring: 0 0 0 4px rgba(78, 115, 223, 0.25);
  --glow-brand: 0 10px 30px rgba(78, 115, 223, 0.16);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   1b. TOKENS — TEMA OSCURO
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;

  --brand-1: #6d8dff;
  --brand-2: #9d7bd8;
  --brand-3: #8b5cf6;
  --brand-1-soft: rgba(109, 141, 255, 0.14);
  --brand-2-soft: rgba(157, 123, 216, 0.14);
  --accent: #2dd4a0;

  /* Superficies con jerarquía de elevación (no todo negro plano):
     bg (fondo) < muted (rellenos) < solid (tarjetas) < raised (capas superiores) */
  --bg: #0b1220;
  --surface: rgba(18, 26, 46, 0.72);
  --surface-solid: #121a2e;
  --surface-muted: #182136;
  --surface-raised: #1d2a44;         /* modales, dropdowns, popups */
  --surface-hover: #1f2b49;          /* hover de filas, items y botones secundarios */
  --text: #e8ecf4;
  --text-muted: #94a3b8;
  --text-soft: #7b8aa3;              /* Texto de énfasis bajo (etiquetas de acordeón) */
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);

  /* Sombras visibles sobre fondo oscuro: negro profundo + anillo sutil de borde */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(148, 163, 184, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(148, 163, 184, 0.06);
  --shadow-lg: 0 10px 22px rgba(0, 0, 0, 0.45), 0 28px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(148, 163, 184, 0.07);
  --ring: 0 0 0 4px rgba(109, 141, 255, 0.28);
  --glow-brand: 0 10px 30px rgba(109, 141, 255, 0.18);

  /* =====================================================================
     VARIABLES DE BOOTSTRAP EN MODO OSCURO
     Bootstrap 5.3 pinta sus componentes con sus propias variables CSS
     (--bs-body-bg, --bs-table-bg, --bs-list-group-bg, --bs-border-color…).
     Como no usamos data-bs-theme="dark", esas variables seguían en valores
     claros y dejaban elementos BLANCOS (tablas, listas, modales, dropdowns)
     sobre el fondo oscuro. Al redefinirlas aquí, TODOS los componentes de
     Bootstrap heredan el tema oscuro automáticamente — sin tocar cada página.
     ===================================================================== */
  --bs-body-bg: var(--bg);
  --bs-body-bg-rgb: 11, 18, 32;            /* rgb(#0b1220) */
  --bs-body-color: var(--text);
  --bs-body-color-rgb: 232, 236, 244;      /* rgb(#e8ecf4) */
  --bs-emphasis-color: var(--text);
  --bs-emphasis-color-rgb: 255, 255, 255;
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-color: var(--text-muted);
  --bs-secondary-bg: var(--surface-muted);
  --bs-tertiary-bg: var(--surface-muted);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: rgba(148, 163, 184, 0.14);

  /* Derivadas que usan las variables anteriores (se redefinen por si
     Bootstrap las resolvió en el primer paint con valores claros) */
  --bs-card-bg: var(--surface-solid);
  --bs-card-cap-bg: var(--surface-muted);
  --bs-card-border-color: var(--border);
  --bs-table-bg: var(--surface-solid);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.035);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-list-group-bg: var(--surface-solid);
  --bs-list-group-color: var(--text);
  --bs-list-group-border-color: var(--border);
  --bs-dropdown-bg: var(--surface-solid);
  --bs-dropdown-color: var(--text);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--text);
  --bs-dropdown-link-hover-bg: var(--surface-muted);
  --bs-dropdown-link-hover-color: var(--text);
  --bs-modal-bg: var(--surface-solid);
  --bs-modal-border-color: var(--border);
  --bs-modal-footer-border-color: var(--border);
  --bs-modal-header-border-color: var(--border);
}

/* ==========================================================================
   2. BASE / RESET / TIPOGRAFÍA
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--brand-1);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--brand-3);
}

img, svg {
  max-width: 100%;
  vertical-align: middle;
}

button {
  font-family: inherit;
}

/* Scrollbar sutil y coherente con el tema */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 35%, transparent);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-muted) 55%, transparent);
  background-clip: content-box;
}

/* ==========================================================================
   3. ACCESIBILIDAD
   ========================================================================== */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

::selection {
  background: var(--brand-1);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   4. ANIMACIONES COMPARTIDAS
   ========================================================================== */
@keyframes themeFadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes themeFloatBlob {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, -50px) scale(1.12); }
  100% { transform: translate(-30px, 30px) scale(0.95); }
}

@keyframes themeGradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes themeSpin {
  to { transform: rotate(360deg); }
}

@keyframes themeFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================================
   5. SECCIÓN LOGIN (index.php)
   --------------------------------------------------------------------------
   Página pública de acceso: fondo animado tipo mesh gradient, tarjeta glass,
   panel de marca y formulario rediseñado. CSS 100% propio (sin Bootstrap).
   ========================================================================== */

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(118, 75, 162, 0.14), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(78, 115, 223, 0.16), transparent 60%),
    var(--bg);
}

/* ---- Fondo decorativo ------------------------------------------------ */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
  animation: themeFloatBlob 22s ease-in-out infinite alternate;
}

.auth-blob-1 {
  width: 460px;
  height: 460px;
  top: -120px;
  left: -100px;
  background: radial-gradient(circle at 30% 30%, rgba(78, 115, 223, 0.9), rgba(78, 115, 223, 0));
}

.auth-blob-2 {
  width: 520px;
  height: 520px;
  bottom: -180px;
  right: -140px;
  background: radial-gradient(circle at 60% 40%, rgba(124, 58, 237, 0.85), rgba(124, 58, 237, 0));
  animation-delay: -8s;
  animation-duration: 26s;
}

.auth-blob-3 {
  width: 340px;
  height: 340px;
  top: 42%;
  left: 55%;
  background: radial-gradient(circle at 50% 50%, rgba(118, 75, 162, 0.7), rgba(118, 75, 162, 0));
  animation-delay: -15s;
  animation-duration: 30s;
}

/* Rejilla sutil */
.auth-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
  opacity: 0.5;
}

/* Grano de película sutil */
.auth-noise {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Botón de alternar tema ------------------------------------------ */
.theme-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 20;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(8deg);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-1);
}

.theme-toggle i {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle:hover i {
  transform: scale(1.15) rotate(-15deg);
}

/* ---- Selector de apariencia con vista previa (login) ------------------ */
.theme-picker {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 30;
}

.theme-picker-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.theme-picker-toggle:hover {
  transform: translateY(-2px) rotate(-6deg);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-1);
}

.theme-picker-panel {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 312px;
  max-width: calc(100vw - 32px);
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  /* visibility oculta el panel del orden de tabulación y del árbol de
     accesibilidad mientras está cerrado (opacity no basta). */
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.theme-picker-panel.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition-delay: 0s;
}

.theme-picker-title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.theme-picker-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.theme-picker-option {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.theme-picker-option:hover {
  border-color: var(--brand-1);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-picker-option.active {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px var(--brand-1-soft), var(--shadow-sm);
}

.theme-picker-option-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

/* Miniaturas de vista previa (mockup estático de cada tema) */
.theme-mini {
  display: flex;
  height: 74px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.theme-mini .mini-side {
  width: 27%;
  flex: 0 0 27%;
}

.theme-mini .mini-main {
  flex: 1;
  min-width: 0;
  padding: 7px;
  display: grid;
  align-content: start;
  gap: 5px;
}

.theme-mini .mini-bar {
  height: 5px;
  border-radius: 3px;
  margin-bottom: 2px;
}

.theme-mini .mini-card {
  height: 12px;
  border-radius: 4px;
}

.theme-mini .mini-card--wide {
  height: 20px;
}

/* Miniatura del tema claro */
.theme-mini-light {
  background: #eef1f8;
}

.theme-mini-light .mini-side {
  background: linear-gradient(180deg, #4e73df 0%, #224abe 100%);
}

.theme-mini-light .mini-bar {
  background: rgba(255, 255, 255, 0.92);
}

.theme-mini-light .mini-card {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* Miniatura del tema oscuro */
.theme-mini-dark {
  background: #0b1220;
}

.theme-mini-dark .mini-side {
  background: linear-gradient(180deg, #182136 0%, #0b1220 100%);
}

.theme-mini-dark .mini-bar {
  background: rgba(255, 255, 255, 0.85);
}

.theme-mini-dark .mini-card {
  background: #121a2e;
  border: 1px solid rgba(148, 163, 184, 0.14);
}

/* Seguir al sistema */
.theme-picker-system {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}

.theme-picker-system:hover {
  color: var(--text);
}

.theme-picker-system i {
  color: var(--brand-1);
  width: 18px;
  text-align: center;
}

.theme-picker-system input {
  accent-color: var(--brand-1);
  cursor: pointer;
}

/* ---- Contenedor principal -------------------------------------------- */
.auth-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1160px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: center;
}

/* ---- Panel de marca --------------------------------------------------- */
.auth-brand {
  color: var(--text);
  animation: themeFadeUp 0.7s ease both;
}

.auth-brand-inner {
  max-width: 480px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  box-shadow: 0 12px 28px rgba(78, 115, 223, 0.45);
  margin-bottom: 26px;
  animation: themeFadeUp 0.7s 0.08s ease both;
}

.auth-title {
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  animation: themeFadeUp 0.7s 0.16s ease both;
}

.auth-title span {
  display: block;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2), var(--brand-3), var(--brand-1));
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: themeGradientShift 8s linear infinite;
}

.auth-tagline {
  font-size: 1.08rem;
  color: var(--text-muted);
  max-width: 420px;
  margin-bottom: 30px;
  animation: themeFadeUp 0.7s 0.24s ease both;
}

.auth-features {
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  display: grid;
  gap: 14px;
  animation: themeFadeUp 0.7s 0.32s ease both;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.auth-features li i {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--brand-1);
  background: var(--brand-1-soft);
  border: 1px solid var(--border);
}

html[data-theme="dark"] .auth-features li i {
  color: var(--brand-1);
  background: var(--brand-1-soft);
}

.auth-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  animation: themeFadeUp 0.7s 0.4s ease both;
}

.auth-stat-chip i {
  color: var(--warning);
}

/* ---- Tarjeta de acceso ------------------------------------------------ */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin-left: auto;
  padding: 42px 40px 36px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--shadow-lg);
  animation: themeFadeUp 0.7s 0.1s ease both;
}

.auth-card-header {
  margin-bottom: 26px;
  text-align: center;
}

.auth-card-header h2 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.auth-card-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

/* Alerta de error */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  background: rgba(231, 76, 60, 0.10);
  border: 1px solid rgba(231, 76, 60, 0.35);
  color: var(--danger);
  font-size: 0.92rem;
  animation: themeFadeUp 0.35s ease both;
}

.auth-alert i {
  margin-top: 2px;
}

/* ---- Formulario ------------------------------------------------------- */
.auth-form {
  display: grid;
  gap: 18px;
}

.auth-field {
  display: grid;
  gap: 7px;
  animation: themeFadeUp 0.6s ease both;
}

.auth-field:nth-child(1) { animation-delay: 0.14s; }
.auth-field:nth-child(2) { animation-delay: 0.2s; }
.auth-field:nth-child(3) { animation-delay: 0.26s; }

.auth-field > label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.auth-input {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input > i {
  position: absolute;
  left: 15px;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition);
}

.auth-input input,
.auth-input select {
  width: 100%;
  padding: 13px 44px 13px 44px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  appearance: none;
  -webkit-appearance: none;
  transition: var(--transition);
}

.auth-input select {
  padding-right: 46px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
}

/* Chevron del select adaptable al tema oscuro */
html[data-theme="dark"] .auth-input select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.auth-input input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.auth-input input:hover,
.auth-input select:hover {
  border-color: var(--border-strong);
}

.auth-input input:focus,
.auth-input select:focus {
  outline: none;
  border-color: var(--brand-1);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--brand-1-soft);
}

.auth-input:focus-within > i {
  color: var(--brand-1);
}

/* Botón de mostrar/ocultar contraseña */
.auth-eye {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.auth-eye:hover {
  color: var(--brand-1);
  background: var(--brand-1-soft);
}

/* Botón principal */
.auth-btn {
  position: relative;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 22px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  box-shadow: 0 10px 26px rgba(78, 115, 223, 0.4);
  transition: var(--transition);
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(78, 115, 223, 0.5);
}

.auth-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
}

.auth-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

/* Brillo que cruza el botón al pasar el ratón */
.auth-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -70%;
  width: 45%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}

.auth-btn:hover::after {
  left: 120%;
}

.auth-btn-icon {
  transition: transform 0.25s ease;
}

.auth-btn:hover .auth-btn-icon {
  transform: translateX(4px);
}

/* Spinner de carga dentro del botón */
.auth-btn .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: themeSpin 0.7s linear infinite;
}

.auth-btn.loading .spinner {
  display: inline-block;
}

.auth-btn.loading .auth-btn-icon {
  display: none;
}

/* Pie de la tarjeta */
.auth-foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 992px) {
  .auth-wrap {
    grid-template-columns: 1fr;
    gap: 34px;
    max-width: 460px;
  }

  .auth-brand {
    text-align: center;
  }

  .auth-brand-inner {
    max-width: none;
  }

  .auth-tagline {
    margin-left: auto;
    margin-right: auto;
  }

  .auth-features {
    justify-content: center;
  }

  .auth-features li {
    justify-content: center;
  }

  .auth-card {
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 600px) {
  .auth-body {
    padding: 24px 16px;
    align-items: flex-start;
  }

  .auth-brand {
    padding-top: 34px;
  }

  .auth-features {
    display: none;
  }

  .auth-logo {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    margin-bottom: 18px;
  }

  .auth-title {
    font-size: 1.8rem;
  }

  .auth-card {
    padding: 30px 24px 26px;
  }

  .theme-toggle {
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
  }

  .theme-picker {
    top: 16px;
    right: 16px;
  }

  .theme-picker-toggle {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .theme-picker-panel {
    width: min(312px, calc(100vw - 32px));
  }
}

/* ==========================================================================
   6. SECCIÓN ADMIN — Dashboard y páginas de gestión (Fase 2)
   --------------------------------------------------------------------------
   Layout de aplicación: topbar + sidebar + contenido. Se aplica a las páginas
   admin que cargan theme.css (migradas). El markup es idéntico al que usan
   las páginas aún no migradas (que siguen con css/varias.css), así que al
   migrar cada página hereda automáticamente este diseño.
   ========================================================================== */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 76px;
}

/* ---- Layout de aplicación ------------------------------------------- */
#wrapper {
  display: flex;
  min-height: 100vh;
}

#page-content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Transparente: el color base lo aporta body con var(--bg) y el fondo
     ambiental (degradados radiales) se ve a través del wrapper. */
  background: transparent;
  transition: var(--transition);
}

#page-content-wrapper .container-fluid {
  flex: 1;
}

/* ---- Topbar ----------------------------------------------------------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 66px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: themeFadeUp 0.4s ease both;
}

.app-topbar-left,
.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-topbar-title i {
  color: var(--brand-1);
  margin-right: 8px;
}

.app-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 50px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
}

.app-user i {
  color: var(--brand-1);
  font-size: 1.1rem;
}

/* Botón hamburguesa */
.btn-toggle-sidebar {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-toggle-sidebar:hover {
  color: var(--brand-1);
  border-color: var(--brand-1);
  transform: translateY(-1px);
}

/* Campana de notificaciones */
.app-bell {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 1.05rem;
  cursor: pointer;
  transition: var(--transition);
}

.app-bell:hover {
  color: var(--brand-1);
  border-color: var(--brand-1);
  transform: translateY(-1px);
}

.app-bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 50px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 3px var(--surface-solid);
}

/* Alternador de tema dentro del topbar (reutiliza .theme-toggle) */
.theme-toggle--topbar {
  position: static;
  width: 42px;
  height: 42px;
  font-size: 1rem;
  box-shadow: none;
}

/* ---- Sidebar ----------------------------------------------------------- */
#sidebar-wrapper {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  height: 100dvh;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  color: #fff;
  background:
    radial-gradient(600px 400px at 120% -10%, rgba(124, 58, 237, 0.35), transparent 60%),
    linear-gradient(180deg, #4e73df 0%, #224abe 100%);
  box-shadow: 4px 0 24px rgba(16, 24, 40, 0.12);
  transition: width var(--transition), transform var(--transition);
}

html[data-theme="dark"] #sidebar-wrapper {
  background:
    radial-gradient(600px 400px at 120% -10%, rgba(124, 58, 237, 0.22), transparent 60%),
    linear-gradient(180deg, #182136 0%, #0b1220 100%);
  border-right: 1px solid var(--border);
}

#sidebar-wrapper.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-heading::before {
  content: "\f188"; /* fa-robot */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 1.25rem;
  color: #ffd700;
  flex: 0 0 auto;
}

.sidebar-heading .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #fff;
  transition: opacity var(--transition);
}

#sidebar-wrapper .list-group {
  flex: 1;
  padding: 12px 10px;
}

#sidebar-wrapper .list-group-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 3px 0;
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
  font-size: 0.93rem;
  white-space: nowrap;
  transition: var(--transition);
}

#sidebar-wrapper .list-group-item i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex: 0 0 20px;
}

#sidebar-wrapper .list-group-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
  transform: translateX(4px);
}

#sidebar-wrapper .list-group-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.10));
  box-shadow: inset 3px 0 0 #ffd700;
}

#sidebar-wrapper.collapsed .sidebar-heading .logo-text,
#sidebar-wrapper.collapsed .list-group-item span {
  opacity: 0;
  display: none;
}

#sidebar-wrapper.collapsed .list-group-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}

#sidebar-wrapper.collapsed .list-group-item i {
  margin: 0;
}

/* ---- Overlay móvil ------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 27, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999;
}

/* ---- Cards / estadísticas ------------------------------------------------- */
#page-content-wrapper .card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  /* Bootstrap fuerza color de texto oscuro (--bs-body-color); en modo oscuro
     debe ser el token del tema para no quedar oscuro sobre oscuro. */
  color: var(--text);
}

#page-content-wrapper .card-header {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

#page-content-wrapper .card-header h5,
#page-content-wrapper .card-header h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-1);
  margin: 0;
}

.card-stat {
  border-left: 4px solid var(--brand-1);
  transition: var(--transition);
  height: 100%;
}

.card-stat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

.stat-card-link:hover {
  color: inherit;
}

/* Encabezados de página */
#page-content-wrapper h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ---- Tablas en modo oscuro ------------------------------------------------ */
html[data-theme="dark"] .table {
  /* Asegura fondo y texto temáticos aunque una variable --bs-* haya quedado
     clara (refuerzo local además de las variables globales de arriba) */
  --bs-table-bg: var(--surface-solid);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  color: var(--text);
  background-color: var(--surface-solid);
}

html[data-theme="dark"] .table thead th {
  color: var(--text-muted);
  border-color: var(--border);
}

html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th {
  border-color: var(--border);
}

html[data-theme="dark"] .table-bordered {
  border-color: var(--border);
}

/* Sintaxis de Bootstrap 5.3: --bs-table-bg-type (striped) y
   --bs-table-bg-state (hover). La sintaxis antigua (--bs-table-accent-bg)
   se ignora en 5.3 y dejaba el rayado/hover en blanco. */
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: rgba(255, 255, 255, 0.05);
}

/* ---- Badges y botones ------------------------------------------------------ */
html[data-theme="dark"] .badge {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-3), var(--brand-1));
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--brand-1);
  border-color: var(--brand-1);
}

.btn-outline-primary:hover {
  background: var(--brand-1);
  border-color: var(--brand-1);
  color: #fff;
}

/* ---- Modal y alertas en modo oscuro ----------------------------------------- */
html[data-theme="dark"] .modal-content {
  background: var(--surface-raised);
  color: var(--text);
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
  border-color: var(--border);
}

html[data-theme="dark"] .modal-header .btn-close {
  filter: invert(1) grayscale(100%);
}

/* ---- Footer ------------------------------------------------------------------ */
footer {
  background: var(--surface-muted) !important;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  margin-top: 30px;
  padding: 20px 0;
}

html[data-theme="dark"] footer .text-dark {
  color: var(--text) !important;
}

html[data-theme="dark"] footer .bg-dark {
  background: transparent !important;
  color: var(--text-muted) !important;
}

/* ---- Móvil: drawer del sidebar ------------------------------------------------ */
@media (max-width: 768px) {
  #sidebar-wrapper {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease !important;
  }

  #sidebar-wrapper.show {
    transform: translateX(0);
  }

  #sidebar-wrapper.collapsed {
    width: 260px !important;
  }

  #sidebar-wrapper.collapsed .sidebar-heading .logo-text,
  #sidebar-wrapper.collapsed .list-group-item span {
    opacity: 1;
    display: inline;
  }

  #sidebar-wrapper.collapsed .list-group-item {
    justify-content: flex-start;
    padding: 12px 14px;
    gap: 12px;
  }

  .app-topbar {
    padding: 0 14px;
  }

  .app-user {
    display: none;
  }
}

/* ---- Refinamientos Fase 2 ------------------------------------------------ */

/* Dropdowns (acciones en móvil) en modo oscuro */
html[data-theme="dark"] .dropdown-menu {
  background: var(--surface-raised);
  border-color: var(--border);
}

html[data-theme="dark"] .dropdown-item {
  color: var(--text);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
  background: var(--surface-hover);
  color: var(--text);
}

/* Acordeón móvil de competencias (antes sin estilos) */
.mobile-competition-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
}

.mobile-competition-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface-muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.mobile-competition-header:hover {
  background: var(--surface-hover);
}

.mobile-competition-body {
  display: none;
  padding: 1rem;
}

.mobile-competition-body.show {
  display: block;
}

.mobile-competition-label {
  font-weight: 600;
  margin-top: 0.5rem;
  color: var(--brand-1);
}

.mobile-competition-value {
  margin-bottom: 0.5rem;
}

/* Anclar el último ítem del sidebar (Cerrar Sesión) al fondo */
#sidebar-wrapper .list-group-item:last-child {
  margin-top: auto;
}

/* ==========================================================================
   7. SECCIÓN COMPETENCIAS — Gestión de competencias (Fase 5)
   --------------------------------------------------------------------------
   Páginas: manage_competitions.php, manage_inactive_competitions.php,
   manage_competition.php, edit_competition.php, competition_detail.php,
   link_competitions.php.
   ========================================================================== */

/* ---- Encabezado de página ---------------------------------------------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
  animation: themeFadeUp 0.4s ease both;
}

.page-header h2 {
  margin: 0;
  font-size: 1.55rem;
}

.page-header h2 i {
  color: var(--brand-1);
  margin-right: 10px;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ---- Breadcrumbs -------------------------------------------------------- */
.breadcrumb {
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
}

.breadcrumb-item a:hover {
  color: var(--brand-1);
}

.breadcrumb-item.active {
  color: var(--brand-1);
  font-weight: 600;
}

html[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-muted);
}

/* ---- Badges de estado ---------------------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
}

.badge.bg-success,
.badge.bg-primary,
.badge.bg-warning,
.badge.bg-info,
.badge.bg-danger,
.badge.bg-secondary {
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.5em 0.85em;
  border-radius: 50px;
}

/* ---- Botón toggle de secciones (Equipos / Jueces) ----------------------- */
.section-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}

.section-toggle-btn h5 {
  margin: 0;
  transition: color var(--transition);
}

.section-toggle-btn > i {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--brand-1-soft);
  color: var(--brand-1);
  font-size: 0.8rem;
  transition: transform 0.3s ease, background var(--transition), color var(--transition);
}

.section-toggle-btn:hover h5 {
  color: var(--brand-3);
}

.section-toggle-btn.collapsed > i {
  transform: rotate(-90deg);
}

/* ---- Acordeones móviles (equipos / jueces / puntuaciones) ---------------- */
.mobile-section-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
}

.mobile-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface-muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.mobile-section-header:hover {
  background: var(--surface-hover);
}

.mobile-section-header i {
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.mobile-section-body {
  display: none;
  padding: 1rem;
}

.mobile-section-body.show {
  display: block;
  animation: themeFadeUp 0.25s ease both;
}

.mobile-section-label {
  font-weight: 600;
  margin-top: 0.5rem;
  color: var(--brand-1);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-section-value {
  margin-bottom: 0.5rem;
}

/* ---- Spinners y estados vacíos -------------------------------------------- */
.loading-spinner {
  text-align: center;
  padding: 2.5rem;
  display: none;
}

.loading-spinner.show {
  display: block;
  animation: themeFadeUp 0.2s ease both;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  color: var(--brand-2);
  opacity: 0.5;
  margin-bottom: 12px;
}

.empty-state h5 {
  color: var(--text);
  font-weight: 600;
}

/* ---- Ordenamiento de columnas -------------------------------------------- */
.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color var(--transition);
}

.sortable:hover {
  color: var(--brand-1);
}

.sort-icon {
  margin-left: 4px;
  color: var(--brand-1);
  font-size: 0.75em;
}

/* ---- Inputs, selects e input-groups en ambos temas ----------------------- */
.input-group-text {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-muted);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
  background-color: var(--surface-solid);
  border-color: var(--brand-1);
  color: var(--text);
  box-shadow: 0 0 0 4px var(--brand-1-soft);
}

html[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .form-label {
  color: var(--text);
}

html[data-theme="dark"] .form-control-plaintext {
  color: var(--text);
}

/* Flecha de los selects adaptada al tema */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 14px;
}

html[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ---- Paginación ----------------------------------------------------------- */
.pagination {
  margin-bottom: 0;
}

.page-link {
  border-radius: 10px !important;
  margin: 0 3px;
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-solid);
  transition: var(--transition);
}

.page-link:hover {
  color: var(--brand-1);
  background: var(--surface-muted);
  border-color: var(--brand-1);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(78, 115, 223, 0.35);
}

html[data-theme="dark"] .page-link {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .page-item.disabled .page-link {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.5;
}

/* ---- Alertas (historial de notificaciones) ------------------------------- */
html[data-theme="dark"] .alert {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .alert-info {
  background: var(--brand-1-soft);
  border-color: color-mix(in srgb, var(--brand-1) 35%, transparent);
  color: var(--text);
}

/* La regla .alert genérica neutralizaba el color semántico de las alertas de
   éxito/peligro/advertencia en modo oscuro (todo quedaba gris). Variantes
   tintadas, con el mismo patrón que .alert-info, para conservar el significado
   del color sin romper el contraste. */
html[data-theme="dark"] .alert-success {
  background: rgba(28, 200, 138, 0.12);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

html[data-theme="dark"] .alert-danger {
  background: rgba(231, 76, 60, 0.12);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--text);
}

html[data-theme="dark"] .alert-warning {
  background: rgba(246, 194, 62, 0.12);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent);
  color: var(--text);
}

/* ---- Botones de acción compactos ----------------------------------------- */
.btn-sm {
  border-radius: 8px;
  font-weight: 600;
  transition: var(--transition);
}

.btn-sm:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-info {
  color: #fff;
  background: linear-gradient(135deg, #0dcaf0, #0aa2c0);
  border: none;
}

.btn-info:hover {
  color: #fff;
  background: linear-gradient(135deg, #0aa2c0, #0dcaf0);
}

.btn-warning {
  color: #1f2937;
  background: linear-gradient(135deg, #f6c23e, #e8a83a);
  border: none;
}

.btn-warning:hover {
  color: #1f2937;
  background: linear-gradient(135deg, #e8a83a, #f6c23e);
}

.btn-success {
  background: linear-gradient(135deg, #1cc88a, #17a673);
  border: none;
}

.btn-success:hover {
  background: linear-gradient(135deg, #17a673, #1cc88a);
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c, #d63031);
  border: none;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #d63031, #e74c3c);
}

.btn-secondary {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

html[data-theme="dark"] .btn-outline-secondary {
  color: var(--text);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* ---- Tabla de competencias: foco en la fila ------------------------------- */
.table-hover tbody tr {
  transition: background var(--transition);
}

/* ---- Formularios dentro de tarjetas --------------------------------------- */
#page-content-wrapper .card-body {
  padding: 20px;
}

/* ---- Tarjetas de conteo en el hub de gestión ------------------------------ */
/* ---- Enlazar competencias (link_competitions.php) ------------------------ */
.competition-check-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.competition-check-list .form-check {
  padding: 10px 14px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.competition-check-list .form-check:last-child {
  border-bottom: none;
}

.competition-check-list .form-check:hover {
  background: var(--surface-hover);
}

.competition-check-list .competition-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-left: 14px;
}

.competition-check-list .competition-row .competition-check {
  margin-left: 0;
}

.competition-check-list .competition-row .form-check-label {
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competition-check-list .competition-row > .d-flex {
  min-width: 0;
}

.competition-check-list .competition-row .btn-group {
  flex-shrink: 0;
}

/* En pantallas pequeñas la fila densa se apila: nombre arriba, orden abajo. */
@media (max-width: 480px) {
  .competition-check-list .competition-row {
    flex-wrap: wrap;
  }

  .competition-check-list .competition-row .form-check-label {
    white-space: normal;
  }
}

/* Items del diálogo "Quitar estaciones" — misma estética que la lista
   compacta de estaciones (tokens del tema, hover y tipografía coherentes). */
.removed-station-item {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: background var(--transition), border-color var(--transition);
}

.removed-station-item:hover {
  background: var(--surface-hover);
}

.removed-station-item:last-child {
  margin-bottom: 0;
}

.removed-station-item .removed-station-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 600;
}

/* El chip de tipo reutiliza .station-type-chip, pero en línea junto al
   nombre no necesita los márgenes pensados para el encabezado de la tabla. */
.removed-station-item .station-type-chip {
  margin: 0;
}

/* Insignia de orden de estación */
.order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(78, 115, 223, 0.35);
}

/* Tarjetas de competencia global */
.group-card {
  border-left: 4px solid var(--brand-1);
  transition: transform var(--transition), box-shadow var(--transition);
}

.group-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.group-competition-chip {
  display: inline-block;
  background: var(--brand-1-soft);
  color: var(--brand-1);
  border: 1px solid color-mix(in srgb, var(--brand-1) 28%, transparent);
  border-radius: 50px;
  padding: 4px 12px;
  margin: 2px 4px 2px 0;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Indicador de TIPO de puntuación dentro de los chips del resumen de
   estaciones enlazadas del encabezado de la global (misma píldora oscura
   translúcida que .group-nav-type del ranking público). */
.group-competition-chip .group-chip-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  white-space: nowrap;
}

.group-competition-chip .group-chip-type i {
  font-size: 0.58rem;
}

/* Caja de estado de la competencia global (fondo claro → temático) */
html[data-theme="dark"] .group-card .bg-light {
  background: var(--surface-muted) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] .group-card .border {
  border-color: var(--border) !important;
}

html[data-theme="dark"] .group-card .border-top {
  border-color: var(--border) !important;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-actions {
    width: 100%;
  }
}

/* ---- Checkboxes (enlazar competencias) en modo oscuro ---------------------- */
html[data-theme="dark"] .form-check-input {
  background-color: var(--surface-muted);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .form-check-input:checked {
  background-color: var(--brand-1);
  border-color: var(--brand-1);
}

/* ---- Switch (toggle) con animación on/off ----------------------------------
   Reemplaza las casillas de verificación de la interfaz. El input permanece en
   el DOM (opacity 0, cubre todo el control) para que el JS existente siga
   leyendo .checked / :checked y escuchando el evento change sin cambios. */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  vertical-align: middle;
  cursor: pointer;
}

.switch input[type="checkbox"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  z-index: 2;
  cursor: pointer;
}

.switch .switch-track {
  position: absolute;
  inset: 0;
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  pointer-events: none;
}

.switch .switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(16, 24, 40, 0.14);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.3);
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  pointer-events: none;
}

/* En modo oscuro el degradado encendido usa tonos de marca claros; el borde
   más oscuro mantiene el thumb delineado sobre él (y sobre el track apagado). */
html[data-theme="dark"] .switch .switch-thumb {
  border-color: rgba(16, 24, 40, 0.38);
}

.switch input[type="checkbox"]:checked ~ .switch-track {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  border-color: transparent;
  box-shadow: 0 0 0 3px var(--brand-1-soft);
}

.switch input[type="checkbox"]:checked ~ .switch-thumb {
  transform: translateX(20px);
}

.switch input[type="checkbox"]:focus-visible ~ .switch-track {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}

.switch:hover .switch-track {
  border-color: var(--brand-1);
}

/* Variante compacta (filas densas, tablas, chips): 34×20px con thumb 13px.
   Úsala con la misma estructura: <label class="switch switch-sm">…</label> */
.switch.switch-sm {
  width: 34px;
  height: 20px;
}

.switch.switch-sm .switch-thumb {
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
}

.switch.switch-sm input[type="checkbox"]:checked ~ .switch-thumb {
  transform: translateX(14px);
}

.switch.switch-sm input[type="checkbox"]:checked ~ .switch-track {
  box-shadow: 0 0 0 2px var(--brand-1-soft);
}

/* ---- Utilidades de color temáticas ----------------------------------------
   text-gray-300/800 venían de varias.css; como las páginas migradas ya no lo
   cargan, se definen aquí para AMBOS temas (evita que queden sin color o que
   solo se vean en modo oscuro). */
.text-gray-300 {
  color: #c4c9d6;
}

.text-gray-800 {
  color: var(--text);
}

/* Fondo claro de Bootstrap (bg-light) oscurecido en tema oscuro: lo usan
   card-header bg-light, modal-header bg-light, cajas bg-light, etc.
   Se usa !important para vencer la utilidad .bg-light de Bootstrap. */
html[data-theme="dark"] .bg-light {
  background-color: var(--surface-muted) !important;
}

html[data-theme="dark"] .bg-white {
  background-color: var(--surface-solid) !important;
}

/* text-muted y text-dark ya quedan temáticos vía --bs-secondary-color /
   --bs-body-color (definidos en los tokens oscuros); estos refuerzos solo
   se aplican en oscuro para las páginas que cargan theme.css. */
html[data-theme="dark"] .text-dark {
  color: var(--text) !important;
}

html[data-theme="dark"] .text-gray-300 {
  color: #6b7280 !important;
}

html[data-theme="dark"] .text-gray-800 {
  color: var(--text) !important;
}

/* ==========================================================================
   8. COMPONENTES DE TERCEROS EN MODO OSCURO (SweetAlert2)
   --------------------------------------------------------------------------
   Los popups de confirmación/notificación (Swal.fire) usan su propio CSS
   blanco. Aquí se tematizan para que también respeten el modo oscuro.
   ========================================================================== */
html[data-theme="dark"] .swal2-popup {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
}

html[data-theme="dark"] .swal2-title,
html[data-theme="dark"] .swal2-html-container {
  color: var(--text);
}

html[data-theme="dark"] .swal2-timer-progress-bar {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
}

html[data-theme="dark"] .swal2-toast {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

html[data-theme="dark"] .swal2-toast .swal2-title {
  color: var(--text);
}

html[data-theme="dark"] .swal2-toast .swal2-html-container {
  color: var(--text);
}

/* ==========================================================================
   9. SECCIÓN JURADO — Paneles del jurado (Fase 3)
   --------------------------------------------------------------------------
   Páginas: judge_dashboard.php, judge_competition.php, judge_points.php.
   Las páginas del jurado no usan el sidebar admin: tienen su propio navbar
   de marca (degradado) + contenido en contenedor centrado.
   ========================================================================== */

/* ---- Navbar del jurado --------------------------------------------------- */
.judge-navbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background:
    radial-gradient(600px 400px at 120% -10%, rgba(124, 58, 237, 0.35), transparent 60%),
    linear-gradient(180deg, #4e73df 0%, #224abe 100%);
  box-shadow: 0 4px 20px rgba(16, 24, 40, 0.18);
}

html[data-theme="dark"] .judge-navbar {
  background:
    radial-gradient(600px 400px at 120% -10%, rgba(124, 58, 237, 0.22), transparent 60%),
    linear-gradient(180deg, #182136 0%, #0b1220 100%);
  border-bottom: 1px solid var(--border);
}

.judge-navbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.judge-navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.judge-navbar-brand:hover {
  color: #fff;
  opacity: 0.9;
}

.judge-navbar-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.judge-navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.judge-navbar-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 50px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: var(--transition);
}

.judge-navbar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Campana dentro del navbar de marca (el contador ya lo da .app-bell-badge) */
.judge-navbar .app-bell {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.judge-navbar .app-bell:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.judge-navbar .app-bell-badge {
  box-shadow: 0 0 0 3px #224abe;
}

html[data-theme="dark"] .judge-navbar .app-bell-badge {
  box-shadow: 0 0 0 3px #182136;
}

/* Alternador de tema dentro del navbar de marca */
.judge-navbar .theme-toggle--topbar {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  box-shadow: none;
}

.judge-navbar .theme-toggle--topbar:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

/* ---- Contenido del jurado ------------------------------------------------ */
.judge-page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 22px 48px;
  animation: themeFadeUp 0.4s ease both;
}

.judge-page h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Encabezado de bienvenida / competencia */
.judge-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

/* ---- Tarjetas de competencia (dashboard del jurado) ---------------------- */
.judge-competition-card .card-body {
  padding: 22px;
}

.judge-competition-card .competition-badge {
  position: absolute;
  top: 14px;
  right: 14px;
}

.judge-competition-card .competition-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 8px;
  padding-right: 90px;
}

/* ---- Tarjetas de equipo (evaluación) ------------------------------------- */
.team-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition);
}

.team-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.team-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.team-card .card-header h5 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}

.team-card .card-body {
  padding: 20px;
}

/* ---- Contador de puntos (punto por punto) -------------------------------- */
.point-counter {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.count-pop {
  animation: themePointPop 0.3s ease;
}

@keyframes themePointPop {
  0%   { transform: scale(0.85); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---- Indicador "en tiempo real" ------------------------------------------ */
.live-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: themeLivePulse 2s infinite;
}

@keyframes themeLivePulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.45; }
  100% { opacity: 1; }
}

/* ---- Botón grande "Agregar punto" ---------------------------------------- */
.btn-add-point {
  background: linear-gradient(90deg, #1cc88a 0%, #13855c 100%);
  border: none;
  border-radius: 50px;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 12px 32px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(28, 200, 138, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter var(--transition);
}

.btn-add-point:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(28, 200, 138, 0.55);
}

.btn-add-point:active:not(:disabled) {
  transform: scale(0.94);
}

.btn-add-point:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---- Barra de progreso (rondas) en modo oscuro --------------------------- */
html[data-theme="dark"] .progress {
  background-color: var(--surface-muted);
}

/* ---- Botón deshacer ------------------------------------------------------- */
.btn-undo-point {
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .judge-navbar-inner {
    padding: 10px 14px;
  }

  .judge-navbar-links {
    width: 100%;
    justify-content: flex-end;
  }

  .judge-page {
    padding: 20px 14px 40px;
  }

  .judge-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-add-point {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    padding: 0;
    font-size: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-add-point .btn-text {
    display: none;
  }

  .btn-add-point i {
    margin: 0 !important;
  }

  .btn-undo-point {
    min-height: 44px;
    font-size: 1rem;
  }
}

/* ==========================================================================
   10. SECCIÓN RANKINGS — Tablas de posiciones (Fase 4)
   --------------------------------------------------------------------------
   Páginas: public_ranking.php (pública), admin_ranking.php y
   admin_dashboard_points.php (admin).
   ========================================================================== */

/* ---- Ranking público (public_ranking.php) -------------------------------- */
/* Página pública sin sesión: fondo de marca en degradado con blobs */
.ranking-public-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(124, 58, 237, 0.45), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(78, 115, 223, 0.5), transparent 60%),
    linear-gradient(135deg, #4e73df 0%, #224abe 60%, #764ba2 100%);
  color: #fff;
}

html[data-theme="dark"] .ranking-public-body {
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(124, 58, 237, 0.35), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(78, 115, 223, 0.4), transparent 60%),
    linear-gradient(160deg, #10182e 0%, #0b1220 60%, #182136 100%);
}

.ranking-public-body .theme-toggle {
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.ranking-public-body .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Encabezado público */
.public-header {
  padding: 34px 16px 12px;
  text-align: center;
  animation: themeFadeUp 0.5s ease both;
}

.public-header h1 {
  font-weight: 800;
  margin-bottom: 4px;
  font-size: 2.2rem;
  color: #fff;
}

.public-header h1 i {
  color: #ffd700;
}

.public-header .competition-name {
  font-size: 1.4rem;
  font-weight: 600;
  color: #fff;
  opacity: 0.95;
}

/* Badge de TIPO de puntuación junto al nombre (vista individual).
   Misma estética que la píldora de los chips de navegación: fondo oscuro
   translúcido + texto blanco, legible sobre el degradado de marca en ambos temas. */
.public-header .competition-name .public-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  vertical-align: middle;
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  white-space: nowrap;
}

.public-header .competition-name .public-type-badge i {
  font-size: 0.62rem;
}

.public-header .competition-desc {
  font-size: 0.95rem;
  opacity: 0.8;
  max-width: 700px;
  margin: 4px auto 0;
}

/* Indicador EN VIVO (reutiliza .live-indicator de la sección JURADO) */
.live-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 16px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.live-badge.live-finished {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.25);
}

.live-badge.live-pending {
  background: rgba(255, 193, 7, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}

.scoring-note {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.75;
}

/* Navegación entre competencias enlazadas */
.group-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px auto 0;
  max-width: 920px;
}

.group-nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 8px 18px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.group-nav-chip:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  transform: translateY(-2px);
}

.group-nav-chip.active {
  background: #ffd700;
  color: #224abe;
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

html[data-theme="dark"] .group-nav-chip.active {
  color: #101828;
}

/* Indicador de TIPO de puntuación dentro de los chips de navegación de estaciones.
   Oscuro translúcido sobre el chip claro; en el chip activo (dorado) se invierte
   al tono azul de marca para mantener el contraste. */
.group-nav-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  white-space: nowrap;
}

.group-nav-type i {
  font-size: 0.6rem;
}

.group-nav-chip.active .group-nav-type {
  background: rgba(34, 74, 190, 0.14);
  color: #224abe;
}

html[data-theme="dark"] .group-nav-chip.active .group-nav-type {
  color: #101828;
}

/* Tarjeta de la tabla de ranking */
.ranking-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  color: var(--text);
  animation: themeFadeUp 0.5s 0.1s ease both;
}

.ranking-table {
  margin-bottom: 0;
}

.ranking-table th {
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  background: var(--surface-muted);
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding: 14px 10px;
  text-align: center;
  white-space: nowrap;
}

/* Cabecera de Participante: alineada a la izquierda como su contenido */
.ranking-table th:nth-child(2) {
  text-align: left;
}

.ranking-table td {
  vertical-align: middle;
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

/* Columna de participante: ancho máximo para que no se expanda y empuje las demás */
.ranking-table td:nth-child(2) {
  text-align: left;
  max-width: 280px;
}

/* Columnas numéricas: alinear a la derecha para minimizar espacio en blanco */
.ranking-table tbody td:nth-child(n+3) {
  text-align: right;
  white-space: nowrap;
}

/* En la vista global, las celdas de puntos y rúbricas por estación van centradas */
.ranking-table tbody td.station-cell {
  text-align: center;
}

.ranking-table tbody tr:last-child td {
  border-bottom: none;
}

.ranking-table tbody tr {
  transition: background-color 0.2s;
}

.ranking-table tbody tr:hover {
  background-color: var(--surface-muted);
}

.ranking-table th.position-col,
.ranking-table td.position-col {
  width: 90px;
}

.participant-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.participant-school {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.total-points {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

/* Cabeceras y celdas de estaciones (desglose) */
.station-header {
  vertical-align: top;
  min-width: 80px;
  white-space: normal;
}

.station-header .station-name {
  display: block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chip de estado por estación */
.station-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 50px;
  white-space: nowrap;
}

.station-status-chip i {
  font-size: 0.55rem;
}

.station-status-chip.st-pending {
  background: #fff3cd;
  color: #856404;
}

.station-status-chip.st-pending i {
  color: #ffc107;
}

.station-status-chip.st-active {
  background: #d4edda;
  color: #155724;
}

.station-status-chip.st-active i {
  color: #28a745;
}

.station-status-chip.st-finished {
  background: #e2e3e5;
  color: #383d41;
}

.station-status-chip.st-finished i {
  color: #6c757d;
}

/* Chip de TIPO de puntuación por estación (puntos rápidos / por rondas):
   usa tokens del tema (se adapta a claro y oscuro) para no competir con
   los colores semánticos del chip de estado. */
.station-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 50px;
  white-space: nowrap;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.station-type-chip i {
  font-size: 0.55rem;
}

/* Leyenda de estados al pie de la tabla */
.ranking-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ranking-legend .legend-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.78rem;
  margin-right: 2px;
}

.ranking-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 0.78rem;
}

.ranking-legend .legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.ranking-legend .legend-dot.legend-pending {
  background: #ffc107;
}

.ranking-legend .legend-dot.legend-active {
  background: #28a745;
}

.ranking-legend .legend-dot.legend-finished {
  background: #6c757d;
}

.station-cell {
  color: var(--brand-1);
  font-weight: 600;
  font-size: 1.05rem;
}

/* Medallas para los primeros 3 lugares */
.position-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
}

.position-1 { background: linear-gradient(135deg, #ffd700, #b8860b); box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
.position-2 { background: linear-gradient(135deg, #c0c0c0, #808080); box-shadow: 0 0 10px rgba(192, 192, 192, 0.5); }
.position-3 { background: linear-gradient(135deg, #cd7f32, #8b4513); box-shadow: 0 0 10px rgba(205, 127, 50, 0.5); }
.position-rest { background: #6c757d; }

.row-1 { background: rgba(255, 215, 0, 0.08); }
.row-2 { background: rgba(192, 192, 192, 0.08); }
.row-3 { background: rgba(205, 127, 50, 0.08); }

/* ---- Número de posición (admin_ranking.php) ------------------------------ */
.position-number {
  font-weight: bold;
  font-size: 1.2em;
  color: var(--brand-1);
}

/* thead.table-primary de admin_ranking.php: Bootstrap lo pinta con
   --bs-primary-bg-subtle (azul claro) que solo cambia con data-bs-theme="dark";
   se oscurece aquí para no repetir el bug de elementos blancos. */
html[data-theme="dark"] .table-primary {
  --bs-table-bg: var(--brand-1-soft);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  color: var(--text);
  background-color: var(--brand-1-soft);
}

html[data-theme="dark"] .table-primary th {
  color: var(--text);
}

/* ---- Efectos de ranking (ranking-effects.js) ----------------------------- */
.move-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
}

.move-chip.move-up {
  background: rgba(28, 200, 138, 0.16);
  color: var(--accent);
}

.move-chip.move-down {
  background: rgba(231, 76, 60, 0.14);
  color: var(--danger);
}

html[data-theme="dark"] .move-chip.move-up {
  color: #2dd4a0;
}

html[data-theme="dark"] .move-chip.move-down {
  color: #f87171;
}

@keyframes themeRowFlashUp {
  0%   { background-color: rgba(28, 200, 138, 0.28); }
  100% { background-color: transparent; }
}

@keyframes themeRowFlashDown {
  0%   { background-color: rgba(231, 76, 60, 0.28); }
  100% { background-color: transparent; }
}

.row-moved-up {
  animation: themeRowFlashUp 1.2s ease;
}

.row-moved-down {
  animation: themeRowFlashDown 1.2s ease;
}

.footer-note {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  padding: 20px 0;
}

@media (max-width: 768px) {
  .total-points { font-size: 1.4rem; }
  .participant-name { font-size: 1rem; }
  .public-header h1 { font-size: 1.7rem; }
  .ranking-table td { padding: 10px 6px; font-size: 0.9rem; }
  .ranking-table th { padding: 10px 6px; font-size: 0.75rem; }
  .ranking-table td:nth-child(2) { max-width: 160px; }
  .station-cell { font-size: 0.9rem; }
}

/* ==========================================================================
   11. SECCIÓN GESTIÓN Y CRUD — Equipos, jurados, auditoría (Fase 5b)
   --------------------------------------------------------------------------
   Páginas: manage_teams.php, manage_judges.php, manage_inactive_teams.php,
   manage_inactive_judges.php, edit_team.php, edit_judge.php,
   assign_judge.php, audit_log.php.
   ========================================================================== */

/* ---- Acordeón móvil de equipos (AJAX: manage_teams / inactive) ---------- */
.mobile-team-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
}

.mobile-team-header {
  background: var(--surface-muted);
  padding: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  transition: background 0.2s ease;
}

.mobile-team-header:hover {
  background: color-mix(in srgb, var(--brand-1) 8%, var(--surface-muted));
}

.mobile-team-header i {
  color: var(--text-soft);
  transition: transform 0.25s ease;
}

.mobile-team-body {
  padding: 1rem;
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.mobile-team-body.show {
  display: block;
  animation: themeFadeIn 0.2s ease;
}

.mobile-team-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin-top: 0.5rem;
}

.mobile-team-value {
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* ---- Acordeón móvil de jurados (AJAX: manage_judges / inactive) --------- */
.mobile-judge-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
}

.mobile-judge-header {
  background: var(--surface-muted);
  padding: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  transition: background 0.2s ease;
}

.mobile-judge-header:hover {
  background: color-mix(in srgb, var(--brand-1) 8%, var(--surface-muted));
}

.mobile-judge-header i {
  color: var(--text-soft);
  transition: transform 0.25s ease;
}

.mobile-judge-body {
  padding: 1rem;
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.mobile-judge-body.show {
  display: block;
  animation: themeFadeIn 0.2s ease;
}

.mobile-judge-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin-top: 0.5rem;
}

.mobile-judge-value {
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* ---- Contador de asignaciones del jurado -------------------------------- */
.assigned-count {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 0.35rem;
  display: block;
}

/* ---- Tarjetas de competencia a asignar (assign_judge.php) --------------- */
.competition-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px;
  margin-bottom: 10px;
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  background: var(--surface-muted);
}

.competition-item:hover {
  border-color: var(--brand-1);
  background: color-mix(in srgb, var(--brand-1) 6%, var(--surface-muted));
  box-shadow: var(--shadow-sm);
}

.competition-item:has(.switch input:checked) .form-check-label {
  color: var(--brand-1);
  font-weight: 700;
}

.competition-item .form-check-label strong {
  color: var(--text);
}

/* ---- Auditoría: badges, celdas de detalle y tarjeta de filtros ---------- */
.action-badge {
  font-size: 0.8rem;
  white-space: nowrap;
}

.audit-details {
  max-width: 320px;
}

.audit-details-cell {
  font-size: 0.88rem;
}

.filter-card .form-label {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.filter-card .alert-light {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}

/* ---- Botón Volver de los formularios de edición ------------------------- */
.btn-back {
  background-color: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-back:hover {
  background-color: color-mix(in srgb, var(--brand-1) 10%, var(--surface-muted));
  border-color: var(--brand-1);
  color: var(--text);
}

/* ---- Acciones en tablas (botones compactos adyacentes) ------------------ */
.table .btn-sm + .btn-sm {
  margin-left: 4px;
}

/* ---- Formularios de registro (tarjeta plegable) ------------------------- */
#teamFormCard,
#judgeFormCard {
  animation: themeFadeUp 0.3s ease both;
}

/* ==========================================================================
   12. ELEVACIÓN, AMBIENTE Y PROFUNDIDAD (ambos temas)
   --------------------------------------------------------------------------
   Sistema de profundidad para los dos temas: jerarquía de superficies
   (bg < muted < solid < raised < hover), sombras multicapa con anillo sutil,
   fondo ambiental con degradados radiales de marca y glow de marca al hover.
   Las reglas base usan tokens temáticos (--shadow-*, --glow-brand,
   --surface-*); las variantes html[data-theme="dark"] ajustan intensidades y
   añaden el bisel "glass edge" (útil sobre fondos oscuros, donde las sombras
   negras se pierden).
   ========================================================================== */

/* Fondo ambiental: degradados radiales sutiles de marca (dinamismo). El
   wrapper del contenido es transparente y deja pasar este fondo. */
body {
  background-image:
    radial-gradient(1100px 700px at 88% -12%, rgba(118, 75, 162, 0.08), transparent 60%),
    radial-gradient(900px 600px at -12% 108%, rgba(78, 115, 223, 0.07), transparent 60%),
    radial-gradient(700px 480px at 50% 118%, rgba(28, 200, 138, 0.03), transparent 60%);
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(1100px 700px at 88% -12%, rgba(124, 58, 237, 0.10), transparent 60%),
    radial-gradient(900px 600px at -12% 108%, rgba(78, 115, 223, 0.09), transparent 60%),
    radial-gradient(700px 480px at 50% 118%, rgba(28, 200, 138, 0.04), transparent 60%);
}

/* Bisel superior claro ("glass edge") en tarjetas y acordeones: profundidad
   sutil en modo oscuro, donde las sombras negras no se perciben. */
html[data-theme="dark"] #page-content-wrapper .card,
html[data-theme="dark"] .team-card,
html[data-theme="dark"] .ranking-card,
html[data-theme="dark"] .mobile-section-item,
html[data-theme="dark"] .mobile-team-item,
html[data-theme="dark"] .mobile-judge-item,
html[data-theme="dark"] .mobile-competition-item {
  border-top-color: rgba(255, 255, 255, 0.09);
}

/* Capas superiores (modales, dropdowns, popups): más elevadas que las tarjetas.
   En claro la elevación se logra con sombra; en oscuro además con color. */
.modal-content,
.dropdown-menu,
.swal2-popup,
.swal2-toast {
  background: var(--surface-raised);
}

.modal-content,
.dropdown-menu,
.swal2-popup {
  box-shadow: var(--shadow-lg);
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .swal2-popup,
html[data-theme="dark"] .swal2-toast {
  border-top-color: rgba(255, 255, 255, 0.12);
}

/* Brillo de marca al hover en tarjetas interactivas (elevación visible).
   Se prefija con #page-content-wrapper para vencer la regla base
   `#page-content-wrapper .card { box-shadow: var(--shadow-sm) }` (ID gana a
   clase); sin ese prefijo el glow nunca se aplicaría sobre las tarjetas. */
#page-content-wrapper .card-stat:hover,
#page-content-wrapper .group-card:hover,
.team-card:hover {
  box-shadow: var(--shadow-md), var(--glow-brand);
}

/* Botones de acción con brillo de marca al hover. Se excluye :focus-visible
   para no tapar el anillo de foco accesible (outline está desactivado). */
.btn-primary:hover:not(:focus-visible),
.btn-success:hover:not(:focus-visible),
.btn-info:hover:not(:focus-visible) {
  box-shadow: var(--glow-brand);
}


