/* FocusFit — Tema unificado portales entrenador y alumno */

body {
  color-scheme: dark;
}

/* Forzar paleta oscura fitness (ignorar modo claro del sistema en portales) */
@media (prefers-color-scheme: light) {
  :root {
    --brand: #CCFF00;
    --brand-hover: #9ECC00;
    --brand-light: #E0FF66;
    --brand-soft: rgba(204, 255, 0, 0.12);
    --brand-glow: rgba(204, 255, 0, 0.25);
    --on-brand: #0A0E14;
    --accent-blue: #00D4FF;
    --accent-blue-soft: rgba(0, 212, 255, 0.12);
    --sidebar: #121820;
    --sidebar-hover: #1A2230;
    --sidebar-active: linear-gradient(135deg, #CCFF00 0%, #9ECC00 100%);
    --bg: #06080C;
    --bg-2: #0A0E14;
    --bg-accent: radial-gradient(ellipse 70% 50% at 80% 0%, rgba(204, 255, 0, 0.08), transparent),
                radial-gradient(ellipse 50% 40% at 10% 90%, rgba(0, 212, 255, 0.06), transparent);
    --surface: #1C2430;
    --surface-elevated: #252F3D;
    --text: #F4F7FB;
    --text-secondary: #C5D0E0;
    --muted: #C5D0E0;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --glass: rgba(18, 24, 32, 0.88);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --focus-ring: rgba(204, 255, 0, 0.45);
  }
  .nav-btn.active { color: var(--on-brand); }
  button.btn:not(.secondary):not(.ghost):not(.link) { color: var(--on-brand); }
  .tab.active { color: var(--on-brand); }
}

.portal-mesh {
  animation: portalMeshDrift 20s ease-in-out infinite alternate;
}

@keyframes portalMeshDrift {
  0% {
    background:
      radial-gradient(ellipse 60% 45% at 85% 5%, rgba(204, 255, 0, 0.1), transparent),
      radial-gradient(ellipse 50% 40% at 5% 95%, rgba(0, 212, 255, 0.08), transparent),
      var(--bg);
  }
  100% {
    background:
      radial-gradient(ellipse 55% 50% at 75% 12%, rgba(204, 255, 0, 0.13), transparent),
      radial-gradient(ellipse 45% 45% at 12% 88%, rgba(0, 212, 255, 0.1), transparent),
      var(--bg);
  }
}

/* ─── Login mejorado ─── */
.login-page {
  background: transparent !important;
  background-image: none !important;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid rgba(204, 255, 0, 0.25);
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 16px;
  animation: badgePulse 3s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(204, 255, 0, 0); }
  50% { box-shadow: 0 0 16px 2px rgba(204, 255, 0, 0.12); }
}

.login-home-link {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  z-index: 2;
}
.login-home-link:hover { color: var(--brand); }

.login-page .card {
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}
.login-page .card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(204, 255, 0, 0.06), transparent 60%);
  pointer-events: none;
}
.login-page .card > * { position: relative; z-index: 1; }

.login-page .card h2 {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
  max-width: 400px;
}
.login-feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(26, 34, 48, 0.7);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}
.login-feature-chip i { color: var(--brand); font-size: 0.9rem; }

.login-page .btn:not(.secondary):not(.ghost) {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 0.95rem;
}
.login-page .btn:not(.secondary):not(.ghost)::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: translateX(-120%);
  animation: btnShine 3.5s ease-in-out infinite;
}
@keyframes btnShine {
  0%, 70%, 100% { transform: translateX(-120%); }
  85% { transform: translateX(120%); }
}

/* ─── App shell logueado ─── */
.app-header {
  background: rgba(6, 8, 12, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.sidebar {
  background: rgba(18, 24, 32, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  position: relative;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.35;
}

.content-shell {
  position: relative;
  min-height: calc(100vh - var(--header-h));
}
.content-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(204, 255, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(204, 255, 0, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.4), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.content-shell .main { position: relative; z-index: 1; }

.page-header {
  position: relative;
  padding-bottom: 16px;
}
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), var(--accent-blue));
}

.page-header h1 {
  color: var(--text);
}

/* Cards con hover marketing */
.card {
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 50%), rgba(204, 255, 0, 0.06), transparent 45%);
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}
.card:hover::before { opacity: 1; }
.card:hover {
  border-color: rgba(204, 255, 0, 0.2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.stat {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.stat .value {
  font-variant-numeric: tabular-nums;
  color: var(--brand);
}

.info-banner {
  border-color: rgba(204, 255, 0, 0.2);
  background: rgba(204, 255, 0, 0.08);
  border-radius: var(--radius-sm);
}

/* Bloques que tenían fondo claro */
.routine-block,
.goal-card,
.phase-card {
  background: rgba(26, 34, 48, 0.8) !important;
  border-color: var(--border) !important;
  color: var(--text);
}
.routine-block li { color: var(--text-secondary) !important; }

.badge.ok { color: var(--brand); }
.badge.warn { color: var(--coral); }
.badge.err { color: var(--err); }

/* Paneles con animación */
.card.panel-enter {
  animation: panelIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Tablas */
.table-wrap {
  background: rgba(18, 24, 32, 0.5);
  backdrop-filter: blur(8px);
}
thead {
  background: rgba(26, 34, 48, 0.9);
}

/* Client avatar gradient fix */
.client-avatar {
  background: linear-gradient(135deg, var(--brand), var(--accent-blue));
  color: var(--on-brand);
}

.user-avatar {
  background: linear-gradient(135deg, var(--brand), var(--brand-hover));
  color: var(--on-brand);
  box-shadow: 0 0 0 3px rgba(204, 255, 0, 0.2);
}

/* ─── Portal alumno móvil ─── */
body.client-mobile-app .page-header h1 {
  color: var(--text);
  background: none;
  -webkit-background-clip: unset;
}

body.client-mobile-app .card {
  border-radius: var(--radius);
}

body.client-mobile-app .page-header::after {
  width: 48px;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    background: rgba(6, 8, 12, 0.95);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
  }
  .mobile-tab.active {
    position: relative;
  }
  .mobile-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--brand);
    border-radius: 2px;
  }
  .btn-workout-start {
    border-radius: 999px;
    position: relative;
    overflow: hidden;
  }
  .exercise-list-mobile li {
    transition: border-color 0.2s, transform 0.2s;
  }
  .exercise-list-mobile li:active {
    transform: scale(0.98);
    border-color: rgba(204, 255, 0, 0.3);
  }
  .history-item {
    transition: transform 0.2s, border-color 0.2s;
  }
  .history-item:hover {
    border-color: rgba(204, 255, 0, 0.25);
    transform: translateX(3px);
  }
}

.workout-overlay {
  background: var(--bg);
}
.workout-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 85% 5%, rgba(204, 255, 0, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 5% 95%, rgba(0, 212, 255, 0.06), transparent);
  pointer-events: none;
  z-index: -1;
}

.install-banner {
  border-radius: var(--radius-sm);
  animation: panelIn 0.4s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .portal-mesh,
  .login-badge,
  .login-page .btn::after {
    animation: none !important;
  }
}
