/* ============================================================
   DESIGN TOKENS
   Paleta del cliente: negro / azul / blanco
   ============================================================ */
:root {
  --color-negro:  #000000;
  --color-azul:   #0A0A7C;
  --color-blanco: #FFFFFF;

  --bg-void:      var(--color-negro);   /* fondo base */
  --bg-panel:     #0A0A14;              /* paneles / cards (negro con tinte azulado) */
  --bg-panel-2:   #12122A;              /* cards elevadas / hover */
  --line:         #23234A;              /* bordes sutiles, derivados del azul */
  --text-hi:      var(--color-blanco);  /* texto principal */
  --text-mid:     #B4B4D6;              /* texto secundario */
  --text-low:     #6A6A96;              /* texto terciario / disabled */
  --accent:       #3D3DE0;              /* azul acento, más vivo que el azul base para legibilidad */
  --accent-dim:   var(--color-azul);
  --accent-text:  var(--color-blanco);  /* texto sobre botones de acento */
  --warn:         #FF6A3D;   /* naranja: alertas / estados pausados */
  --danger:       #FF4D4D;

  --font-display: 'Bebas Neue', 'Oswald', sans-serif;
  --font-body:    'Inter', -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}


.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.pill {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border, #333);
  background: transparent;
  color: var(--text-mid, #ccc);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  border-color: var(--accent, #d4ff2b);
  color: var(--text-hi, #fff);
}

.pill.selected {
  background: var(--accent, #d4ff2b);
  border-color: var(--accent, #d4ff2b);
  color: #111;
  font-weight: 700;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-void);
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::selection { background: var(--accent); color: var(--accent-text); }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.03em;
  line-height: 1;
}
.brand span { color: var(--accent); }
.brand small {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-low);
  letter-spacing: 0.12em;
  margin-top: 4px;
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-panel-2); color: var(--text-hi); }
.nav-item.active {
  background: var(--bg-panel-2);
  color: var(--text-hi);
  border-left: 2px solid var(--accent);
}
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-low);
}

.main {
  padding: 32px 40px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: 0.01em;
  margin: 0;
}
.topbar .subtitle { color: var(--text-mid); font-size: 14px; margin-top: 4px; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-panel-2);
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 600;
  transition: transform .1s, background .15s;
}
.btn:hover { background: #2A2E38; }
.btn:active { transform: scale(0.97); }

.btn-accent {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-mid);
}
.btn-ghost:hover { color: var(--text-hi); background: var(--bg-panel-2); }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.wod-card {
  position: relative;
}

.wod-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-mid, #ccc);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s ease;
}

.wod-card:hover .wod-delete-btn {
  opacity: 1;
}

.wod-delete-btn:hover {
  background: #e5484d;
  color: #fff;
}

/* ============================================================
   CARDS / STATS
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-low);
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 32px;
  margin-top: 6px;
}
.stat-card .value.accent { color: var(--accent); }

/* ============================================================
   TABLA DE ATLETAS
   ============================================================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-low);
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 14px 22px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text-hi);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-panel-2); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-panel-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 10px;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-active { background: rgba(61,61,224,0.18); color: var(--accent); }
.badge-paused { background: rgba(255,106,61,0.15); color: var(--warn); }
.badge-cancelled { background: rgba(255,77,77,0.15); color: var(--danger); }

/* ============================================================
   VISTA SEMANAL (LUN - DOM)
   ============================================================ */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.week-nav .week-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-mid);
}

.week-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.day-col {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.day-col.is-today { border-color: var(--accent); }

.day-col-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.day-col-header .day-name {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.day-col-header .day-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  margin-top: 2px;
}

.day-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.wod-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.wod-card:hover { border-color: var(--accent); }
.wod-card .wod-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 700;
}
.wod-card .wod-title {
  font-size: 13px;
  font-weight: 600;
  margin-top: 3px;
}

.day-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-low);
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
}

.add-wod-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-low);
  font-size: 12px;
  font-weight: 600;
  transition: color .15s, border-color .15s;
}
.add-wod-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,11,13,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

label { font-size: 12px; color: var(--text-mid); font-weight: 600; }
input, select, textarea {
  width: 100%;
  background: var(--bg-void);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-hi);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  margin-top: 6px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 90px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-void);
  background-image: radial-gradient(circle at 20% 20%, rgba(61,61,224,0.12), transparent 40%);
}
.login-card {
  width: 380px;
  max-width: 90vw;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.login-card .brand { text-align: center; margin-bottom: 28px; }
.login-card .btn-accent { width: 100%; justify-content: center; margin-top: 8px; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

/* ============================================================
   NAV MOBILE (barra superior + drawer del sidebar)
   ============================================================ */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-topbar .brand { font-size: 20px; }

.mobile-menu-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-hi);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-close-btn {
  display: none;
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mid);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: -12px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ============================================================
   TABLAS: SCROLL HORIZONTAL EN PANTALLAS CHICAS
   ============================================================ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   RESPONSIVE: BREAKPOINTS
   Van al final a propósito: como tienen la misma especificidad
   que las reglas de arriba, si quedaran antes, la última regla
   del archivo (la de arriba) les ganaría siempre, sin importar
   el tamaño de pantalla. Esto es justo lo que rompió el menú
   mobile la primera vez.
   ============================================================ */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
  .mobile-topbar { display: flex; }
  .topbar { flex-wrap: wrap; gap: 12px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    max-width: 85vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-close-btn { display: flex; }

  .sidebar-overlay.open { display: block; }

  .week-board { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .table-scroll table { min-width: 480px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .share-link-row { flex-wrap: wrap; }
  .share-link-row input { flex: 1 1 100%; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.btn-block {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   TABLERO SEMANAL: ESTADOS DINÁMICOS (bloqueado / completado)
   ============================================================ */
.day-col.is-locked {
  opacity: 0.55;
}

.day-locked {
  text-align: center;
  padding: 20px 8px;
}
.day-locked-icon {
  font-size: 20px;
  margin-bottom: 6px;
}
.day-locked-text {
  font-size: 12px;
  color: var(--text-low);
}

.wod-card.is-completed {
  border-color: #22c55e;
}
.wod-card .wod-title.has-check {
  padding-right: 26px;
}

.wod-check-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--text-low);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background .15s, border-color .15s;
}
.wod-check-btn.is-completed {
  border-color: #22c55e;
  background: #22c55e;
}
.wod-check-btn .check-mark {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   MODAL: DETALLE DE ENTRENAMIENTO (vista atleta)
   ============================================================ */
.wod-detail-type {
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.wod-detail-day {
  color: var(--text-low);
  font-size: 13px;
  margin-bottom: 16px;
}
.wod-detail-content {
  white-space: pre-wrap;
  color: var(--text-hi);
  font-size: 15px;
  line-height: 1.6;
}
.wod-detail-video {
  margin-top: 20px;
  display: none;
}

/* ============================================================
   MODAL: COMPARTIR LINK DE INVITACIÓN
   ============================================================ */
.share-link-row {
  display: flex;
  gap: 8px;
}
.share-link-input {
  flex: 1;
  margin-top: 0;
  font-size: 12px;
}
.share-link-feedback {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
}
.share-link-feedback.success { color: var(--accent); }
.share-link-feedback.error { color: var(--text-mid); }

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  border: none;
}
.btn-whatsapp:hover { background: #1EBE5A; }

/* ============================================================
   BANNER DE ERROR (feedback visible cuando falla una carga)
   ============================================================ */
.error-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255,77,77,0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}
.error-banner.open { display: flex; }
.error-banner button {
  background: transparent;
  border: none;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}

/* ============================================================
   ESTADOS DE CARGA (skeleton)
   ============================================================ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.skeleton-value {
  display: inline-block;
  width: 48px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-2);
  animation: skeleton-pulse 1.3s ease-in-out infinite;
}

.table-empty-state {
  color: var(--text-low);
  text-align: center;
  padding: 32px;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

.skeleton-day {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 320px;
  animation: skeleton-pulse 1.3s ease-in-out infinite;
}