/* ==========================================================================
   Dinámicas Betterware — Liquid Glass design
   Rediseño inspirado en el lenguaje "Liquid Glass" de Apple (2025):
   superficies translúcidas con desenfoque, cápsulas, bordes luminosos y
   profundidad por capas sobre un fondo vibrante. Identidad rosa Betterware.
   ========================================================================== */
:root {
  --bw-pink:       #e4007c;
  --bw-pink-dark:  #b30062;
  --bw-pink-light: #fde8f3;
  --ink:           #33202b;
  --muted:         #7d6674;
  --gold:          #e8b400;
  --track-h: 64px;

  /* Tokens de vidrio */
  --glass:        rgba(255, 255, 255, .52);
  --glass-strong: rgba(255, 255, 255, .70);
  --glass-soft:   rgba(255, 255, 255, .34);
  --glass-border: rgba(255, 255, 255, .65);
  --glass-inner:  inset 0 1px 0 rgba(255, 255, 255, .85), inset 0 -1px 0 rgba(255, 255, 255, .25);
  --glass-shadow: 0 8px 32px rgba(51, 32, 43, .14);
  --blur: 24px;
  --r-card: 26px;
  --r-capsule: 999px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  /* Fondo vibrante: el vidrio necesita color detrás para lucir */
  background:
    radial-gradient(1000px 600px at 12% -8%,  #ffd3ea 0%, transparent 60%),
    radial-gradient(900px 640px  at 108% 12%, #ffe3c9 0%, transparent 55%),
    radial-gradient(760px 560px  at 84% 96%,  #e6d5ff 0%, transparent 58%),
    radial-gradient(680px 520px  at -6% 88%,  #ffd9e6 0%, transparent 55%),
    linear-gradient(170deg, #fff5fa 0%, #fdeef6 45%, #f7ecf8 100%);
  background-attachment: fixed;
}

/* Burbujas decorativas flotando al fondo (capa más profunda) */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  pointer-events: none;
}
body::before {
  width: 46vmin; height: 46vmin;
  left: -10vmin; top: 22vh;
  background: radial-gradient(circle at 32% 30%, #ff7ec0, #e4007c 70%);
  animation: float-a 26s ease-in-out infinite alternate;
}
body::after {
  width: 38vmin; height: 38vmin;
  right: -8vmin; bottom: 8vh;
  background: radial-gradient(circle at 60% 35%, #ffc46b, #ff8ab5 75%);
  animation: float-b 32s ease-in-out infinite alternate;
}
@keyframes float-a { to { transform: translate(9vmin, -7vmin) scale(1.12); } }
@keyframes float-b { to { transform: translate(-8vmin, -9vmin) scale(.92); } }
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ---------- Encabezado (barra de vidrio rosado) ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 18px 4px;
  padding: 18px 26px;
  color: #fff;
  background: linear-gradient(120deg, rgba(228, 0, 124, .82), rgba(179, 0, 98, .78));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.6);
  backdrop-filter: blur(var(--blur)) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: var(--r-card);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.hero h1 { margin: 0; font-size: 1.7rem; letter-spacing: .3px; text-shadow: 0 1px 6px rgba(0,0,0,.18); }
.hero .tagline { margin: 4px 0 0; opacity: .92; font-style: italic; }
.hero nav { display: flex; gap: 10px; flex-wrap: wrap; }
.edit-head { display: flex; align-items: center; gap: 16px; }

/* ---------- Botones (cápsulas) ---------- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--r-capsule);
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-size: .95rem;
  transition: transform .18s cubic-bezier(.2,.8,.3,1.2), box-shadow .18s ease, background .18s ease;
}
.btn:hover  { transform: translateY(-2px) scale(1.02); }
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #ff2f99 0%, var(--bw-pink) 45%, var(--bw-pink-dark) 100%);
  border-color: rgba(255, 255, 255, .45);
  box-shadow: 0 6px 20px rgba(228, 0, 124, .38), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(228, 0, 124, .48), inset 0 1px 0 rgba(255, 255, 255, .55); }

.btn-outline {
  color: inherit;
  background: rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  border-color: rgba(255, 255, 255, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-outline:hover { background: rgba(255, 255, 255, .38); }

.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-lg { padding: 13px 36px; font-size: 1.05rem; }

.btn-danger {
  color: #fff;
  background: linear-gradient(180deg, #e05b4b 0%, #c0392b 60%, #a02e22 100%);
  border-color: rgba(255, 255, 255, .4);
  box-shadow: 0 6px 18px rgba(192, 57, 43, .38), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.btn-danger:hover { box-shadow: 0 10px 24px rgba(192, 57, 43, .5); }

.btn-ghost { color: var(--bw-pink-dark); }

/* ---------- Superficie de vidrio base ---------- */
.card,
.track-panel,
.ranking-panel,
.dyn-card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.7);
  backdrop-filter: blur(var(--blur)) saturate(1.7);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  box-shadow: var(--glass-shadow), var(--glass-inner);
}
/* Fallback si el navegador no soporta backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .track-panel, .ranking-panel, .dyn-card, .hero, .tabs, .btn-outline {
    background-color: rgba(255, 255, 255, .92);
  }
}

/* ---------- Layout carrera ---------- */
.race-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 20px 18px;
  align-items: start;
}
@media (max-width: 980px) { .race-layout { grid-template-columns: 1fr; } }

.track-panel { padding: 20px 24px; }
.track-endpoints {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.track-endpoints figure { margin: 0; text-align: center; font-size: .82rem; color: var(--muted); }
.track-endpoints img {
  width: 86px; height: 86px;
  object-fit: cover;
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,.7);
}

.track { position: relative; }
.lane {
  position: relative;
  height: var(--track-h);
  border-bottom: 1px dashed rgba(228, 0, 124, .18);
}
.lane:last-child { border-bottom: none; }
.lane::after {                      /* banderita de meta al final del carril */
  content: "🏁";
  position: absolute;
  right: -4px; top: 50%;
  transform: translateY(-50%);
  opacity: .35;
  font-size: .9rem;
}
.runner {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-0%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: left 1.1s cubic-bezier(.22, .8, .36, 1);
  will-change: left;
  z-index: 1;
}
.runner .avatar { flex: none; }
.runner .chip {
  color: var(--bw-pink-dark);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px) saturate(1.6);
  backdrop-filter: blur(12px) saturate(1.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-capsule);
  padding: 4px 12px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(51, 32, 43, .12), inset 0 1px 0 rgba(255, 255, 255, .8);
}
.runner.leader .avatar {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(232, 180, 0, .30), 0 6px 16px rgba(232, 180, 0, .35);
}
.runner.leader .chip {
  background: linear-gradient(180deg, rgba(255, 249, 224, .92), rgba(255, 240, 190, .85));
  color: #8a6d00;
  border-color: rgba(232, 180, 0, .45);
}

.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, .9);
  background: #fff;
  box-shadow: 0 4px 12px rgba(51, 32, 43, .22), 0 0 0 1px rgba(228, 0, 124, .35);
}
.avatar-sm { width: 34px; height: 34px; border-width: 2px; vertical-align: middle; margin-right: 8px; }
.avatar-lg { width: 72px; height: 72px; }

.track-note { color: var(--muted); font-size: .85rem; margin: 14px 0 0; }

/* ---------- Ranking ---------- */
.ranking-panel { padding: 20px 22px; }
.ranking-panel h2 { margin: 0 0 12px; font-size: 1.15rem; }
.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 14px;
  font-size: .95rem;
  transition: background .18s ease;
}
.ranking li:hover { background: rgba(255, 255, 255, .45); }
.ranking .pos { width: 2em; text-align: center; font-weight: 700; color: var(--bw-pink-dark); }
.ranking .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .pts { font-weight: 700; color: var(--bw-pink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.updated { color: var(--muted); font-size: .8rem; text-align: right; margin: 10px 0 0; }

/* ---------- Contenido / tarjetas ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 18px 44px; }
.card { padding: 22px 26px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 1.15rem; }
.card.danger { border-color: rgba(224, 91, 75, .5); }

.flash {
  color: #14691f;
  background: linear-gradient(180deg, rgba(226, 250, 230, .85), rgba(208, 244, 214, .75));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(120, 200, 130, .55);
  border-radius: 16px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}
.flash-error {
  color: #8c2016;
  background: linear-gradient(180deg, rgba(253, 232, 229, .88), rgba(250, 214, 209, .78));
  border-color: rgba(224, 91, 75, .5);
}
.muted { color: var(--muted); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: 16px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 12px; text-align: left; font-size: .92rem; }
thead th {
  color: var(--bw-pink-dark);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(228, 0, 124, .22);
}
tbody tr { border-bottom: 1px solid rgba(255, 255, 255, .5); transition: background .15s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .5); }
.rank-cell { font-weight: 700; color: var(--bw-pink-dark); }
.name-cell { white-space: nowrap; font-weight: 600; }
.miles-cell { font-weight: 800; color: var(--bw-pink); font-variant-numeric: tabular-nums; }

.months-table th { white-space: nowrap; }
.months-table td { text-align: center; }
.check input { width: 20px; height: 20px; accent-color: var(--bw-pink); cursor: pointer; }

/* ---------- Contadores (métricas) ---------- */
.counters { display: flex; gap: 28px; flex-wrap: wrap; }
.counter label { display: block; font-weight: 600; margin-bottom: 6px; }
.counter small { color: var(--muted); font-weight: 400; }
.counter input {
  width: 140px;
  padding: 11px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bw-pink-dark);
  background: var(--glass-strong);
  box-shadow: inset 0 1px 3px rgba(51, 32, 43, .08);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.counter input:focus {
  outline: none;
  border-color: var(--bw-pink);
  box-shadow: 0 0 0 4px rgba(228, 0, 124, .18);
}

.actions { margin: 6px 0 22px; }
.quick .inline { display: inline-block; margin-right: 10px; }
.quick .btn-outline { color: var(--bw-pink-dark); }

/* ---------- Historial ---------- */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, .5); font-size: .92rem; }
.history li:last-child { border-bottom: none; }
.history .when { color: var(--muted); font-size: .8rem; margin-right: 8px; }
.history .miles-after { color: var(--bw-pink); font-weight: 700; margin-left: 6px; }

/* ---------- Landing (tarjetas de dinámicas) ---------- */
.dyn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}
.dyn-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .22s cubic-bezier(.2,.8,.3,1.1), box-shadow .22s ease;
}
.dyn-card:hover {
  transform: translateY(-5px) scale(1.012);
  box-shadow: 0 18px 44px rgba(228, 0, 124, .22), var(--glass-inner);
}
.dyn-thumb {
  height: 150px;
  background: linear-gradient(120deg, rgba(253, 232, 243, .7), rgba(255, 240, 225, .6));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--glass-border);
}
.dyn-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dyn-thumb-emoji { font-size: 64px; filter: drop-shadow(0 6px 14px rgba(51, 32, 43, .25)); }
.dyn-card-body { padding: 18px 22px 22px; }
.dyn-card-body h2 { margin: 0 0 4px; font-size: 1.2rem; color: var(--bw-pink-dark); }
.dyn-card-body p { margin: 3px 0; }
.dyn-meta { font-size: .88rem; }
.dyn-card-body .btn { margin-top: 12px; }

/* ---------- Pestañas de dinámica (segmented control de vidrio) ---------- */
.tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 6px;
  background: var(--glass-soft);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-capsule);
  box-shadow: var(--glass-inner);
}
.tab {
  padding: 9px 20px;
  border-radius: var(--r-capsule);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.tab:hover { background: rgba(255, 255, 255, .5); }
.tab-active {
  color: #fff;
  background: linear-gradient(180deg, #ff2f99, var(--bw-pink) 55%, var(--bw-pink-dark));
  border-color: rgba(255, 255, 255, .45);
  box-shadow: 0 4px 14px rgba(228, 0, 124, .4), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.tab-active:hover { background: linear-gradient(180deg, #ff2f99, var(--bw-pink) 55%, var(--bw-pink-dark)); }

/* ---------- Formularios (dinámicas / participantes) ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto !important; } }
.span-2 { grid-column: span 2; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { color: var(--muted); font-weight: 400; }
.field input[type=text],
.field input[type=number],
.field input[type=month],
.field input[type=date] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-size: .98rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: inset 0 1px 3px rgba(51, 32, 43, .08);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--bw-pink);
  box-shadow: 0 0 0 4px rgba(228, 0, 124, .18);
}
.field input[type=file] { display: block; margin-top: 4px; font-size: .9rem; }
.field-check { display: flex; align-items: center; gap: 10px; }
.field-check input { width: 20px; height: 20px; accent-color: var(--bw-pink); }
.field-check span { font-weight: 600; }
.img-preview {
  display: block;
  width: 84px; height: 84px;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin: 4px 0 6px;
}

/* ---------- Detalles admin ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.row-actions { white-space: nowrap; }
.row-actions .inline { display: inline-block; margin-left: 4px; }
.avatar-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--glass-strong);
}
.endpoint-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 86px; height: 86px;
  font-size: 44px;
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, .7);
}

/* ---------- Setup / pie ---------- */
.setup-page .card { max-width: 640px; margin: 40px auto; }
.setup-page .btn { margin-top: 8px; }
.foot {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 8px 20px 28px;
}
