/* ============================================================
   FitAI — Estilos principales
   Tema: Energético, oscuro, profesional
   Fuentes: Barlow Condensed (títulos) + DM Sans (cuerpo)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:        #0d0f14;
  --bg2:       #161b24;
  --bg3:       #1e2633;
  --card:      #1a2030;
  --border:    rgba(255,255,255,0.07);
  --accent:    #00e5a0;
  --accent2:   #00b8ff;
  --danger:    #ff4d6d;
  --warn:      #ffa500;
  --text:      #e8ecf0;
  --muted:     #7a8499;
  --radius:    14px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Tipografía ─────────────────────────────────────────── */
h1, h2, h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }

/* ── Scrollbar personalizada ──────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* ── Layout principal ──────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── PANTALLAS ─────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.navbar-brand span { color: var(--accent); }
.navbar-nav { display: flex; gap: 8px; align-items: center; }
.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: all .2s;
}
.nav-btn:hover, .nav-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}
.nav-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── Contenedor central ─────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-sm { padding: 16px; }

/* ── Grid ───────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ── Metric cards ───────────────────────────────────────── */
.metric-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}
.metric-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.metric-unit { font-size: 1rem; color: var(--muted); }

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #0d0f14;
}
.btn-primary:hover { background: #00ffb3; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,229,160,0.35); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-secondary:hover { background: rgba(0,229,160,0.08); }
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,77,109,0.1); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }

/* ── Formularios ─────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color .2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,229,160,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
select.form-control { cursor: pointer; }

/* ── Auth screen ─────────────────────────────────────────── */
#screen-auth {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
#screen-auth::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,229,160,0.06) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}
.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}
.auth-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  margin-bottom: 8px;
}
.auth-logo span { color: var(--accent); }
.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 36px;
}
.auth-tabs {
  display: flex;
  background: var(--bg3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  transition: all .2s;
}
.auth-tab.active {
  background: var(--bg2);
  color: var(--accent);
}

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-danger { background: rgba(255,77,109,0.12); border: 1px solid rgba(255,77,109,0.3); color: #ff4d6d; }
.alert-success { background: rgba(0,229,160,0.1); border: 1px solid rgba(0,229,160,0.3); color: var(--accent); }

/* ── Badge de nivel ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-green { background: rgba(0,229,160,0.15); color: var(--accent); border: 1px solid rgba(0,229,160,0.3); }
.badge-blue  { background: rgba(0,184,255,0.15); color: var(--accent2); border: 1px solid rgba(0,184,255,0.3); }
.badge-warn  { background: rgba(255,165,0,0.15);  color: var(--warn); border: 1px solid rgba(255,165,0,0.3); }
.badge-red   { background: rgba(255,77,109,0.15); color: var(--danger); border: 1px solid rgba(255,77,109,0.3); }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-bar {
  background: var(--bg3);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ── Gráfico de peso ─────────────────────────────────────── */
#chart-peso { width: 100%; height: 200px; }

/* ── ===== TIMER SCREEN ===== ─────────────────────────────── */
#screen-timer {
  background: var(--bg);
  flex-direction: column;
  align-items: center;
}
.timer-header {
  width: 100%;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.timer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.timer-phase {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 12px;
}
.timer-exercise-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.1;
}
.timer-exercise-desc {
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 28px;
  max-width: 400px;
}
.timer-circle {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 28px;
}
.timer-circle svg { transform: rotate(-90deg); }
.timer-circle-bg { fill: none; stroke: var(--bg3); stroke-width: 8; }
.timer-circle-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.98s linear;
}
.timer-circle.rest .timer-circle-fill { stroke: var(--accent2); }
.timer-time {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}
.timer-time small { display: block; font-size: 0.9rem; font-weight: 400; color: var(--muted); margin-top: 4px; }
.timer-controls { display: flex; gap: 16px; justify-content: center; margin-top: 8px; }
.timer-progress-info {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.timer-stat { text-align: center; }
.timer-stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.timer-stat-val { font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; font-weight: 700; }

/* ── Rutina lista preview ─────────────────────────────────── */
.routine-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .2s;
}
.routine-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(0,229,160,0.1);
}
.exercise-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-list-item:last-child { border-bottom: none; }
.exercise-num {
  width: 28px; height: 28px;
  background: var(--bg3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 7px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all .2s;
}
.tab-btn.active { background: var(--card); color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 12px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 20px 16px; }
  .auth-box { padding: 32px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .timer-main { padding: 16px; }
}

/* ── Navegación: lógica de visibilidad ───────────────────
   Móvil (<900px):  barra inferior visible, tabs ocultos
   Desktop (≥900px): tabs visibles, barra oculta          */

.desktop-tabs  { display: none; }
.bottom-nav    { display: none; }  /* JS controla visibilidad */

@media (min-width: 900px) {
  .desktop-tabs  { display: block !important; }
  .bottom-nav    { display: none !important; }
  .container     { padding-bottom: 32px !important; }
}

/* ── Desktop tabs ─────────────────────────────────────── */
.desktop-tabs {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.desktop-tabs-inner {
  display: flex;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
}
.desktop-tabs .tab-btn {
  padding: 14px 20px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  font-size: 0.88rem;
  color: var(--muted);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.desktop-tabs .tab-btn:hover { color: var(--text); }
.desktop-tabs .tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Bottom nav (móvil) ──────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(22, 27, 36, 0.97);
  border-top: 1px solid var(--border);
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: 64px;
  align-items: stretch;
  justify-content: space-around;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 2px 6px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: color 0.15s;
  min-width: 0;
}
.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 24px; height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  transition: transform 0.2s;
}
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active::before { transform: translateX(-50%) scaleX(1); }

.bnav-icon {
  width: 22px; height: 22px;
  display: block;
  background: none !important;
  fill: none !important;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: transform 0.15s;
  overflow: visible;
}
.bnav-icon * {
  fill: none !important;
  background: none !important;
}
.bottom-nav-item.active .bnav-icon { transform: translateY(-1px); }

/* Botón central (Generar IA) */
.bottom-nav-center { flex: 1.3; }
.bottom-nav-center::before { display: none; }
.bnav-center-btn {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s;
  box-shadow: 0 0 20px rgba(0,229,160,0.3);
}
.bottom-nav-center .bnav-icon {
  stroke: #0d0f14;
  width: 19px; height: 19px;
}
.bottom-nav-center.active .bnav-center-btn,
.bottom-nav-center:active .bnav-center-btn { transform: scale(0.93); }
.bottom-nav-center.active { color: var(--accent); }

/* Contenido no tapado por la barra */
.container { padding-bottom: 80px; }
#screen-timer .timer-main { padding-bottom: 16px; }
  .bottom-nav   { display: none; }
  .container    { padding-bottom: 32px; }
}
