@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #0A0C10;
  --card: #14181F;
  --card-alt: #0D1015;
  --accent: #3D7BF5;
  --accent-15: rgba(61, 123, 245, 0.15);
  --accent-30: rgba(61, 123, 245, 0.3);
  --accent-40: rgba(61, 123, 245, 0.4);
  --text: #F5F6F7;
  --text-muted: #8B9099;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --danger: #F5473D;
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 18px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; }

button, input, select, textarea { font-family: inherit; }

/* ---------- Tipografía ---------- */

.t5-display { font-family: var(--font-display); }

h1.t5-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 2px;
}

p.t5-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.t5-big-number {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
}

/* ---------- Encabezado de pantalla ---------- */

.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.back-link {
  color: var(--text-muted);
  font-size: 20px;
  text-decoration: none;
  line-height: 1;
  padding: 4px 2px;
}

.screen-header .titles { flex: 1; min-width: 0; }
.screen-header h1.t5-title { margin-bottom: 0; }
.screen-header p.t5-subtitle { margin: 2px 0 0; }

/* ---------- Botones ---------- */

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 13px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:disabled { opacity: 0.5; }

.btn-dashed {
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--accent);
  padding: 13px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
}

.btn-danger-text {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 0;
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
}

.card-accent {
  background: var(--card);
  border: 0.5px solid var(--accent-30);
  border-radius: 12px;
  padding: 14px;
}

/* ---------- Listas (perfiles, rutinas) ---------- */

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 0.5px solid var(--line);
  text-decoration: none;
  color: inherit;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.list-item:last-child { border-bottom: none; }
.list-item .chevron { color: var(--text-muted); font-size: 14px; }
.list-item .label { flex: 1; min-width: 0; }
.list-item .label .name { color: var(--text); font-size: 13px; font-weight: 500; }
.list-item .label .meta { color: var(--text-muted); font-size: 10px; margin-top: 3px; }

/* ---------- Avatar ---------- */

.avatar {
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--card);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 56px; height: 56px; font-size: 20px; }
.avatar-lg { width: 68px; height: 68px; font-size: 22px; }

/* ---------- Badges / chips ---------- */

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 6px;
}

.badge-accent {
  display: inline-block;
  background: var(--accent-15);
  color: var(--accent);
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  background: var(--card);
  color: var(--text-muted);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.chip.active { background: var(--accent); color: #FFFFFF; font-weight: 500; }

/* ---------- Tabs (segmentado) ---------- */

.tabs {
  display: flex;
  background: var(--card);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}

.tab.active { background: var(--accent); color: #FFFFFF; font-weight: 500; }

/* ---------- Formularios ---------- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  margin-bottom: 5px;
}

.field input, .field select {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 0.5px solid var(--line-strong);
  padding: 8px 0;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.field input:focus, .field select:focus { border-bottom-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }

.photo-picker {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.photo-picker label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.photo-picker input[type="file"] { display: none; }
.photo-picker .hint { color: var(--accent); font-size: 10px; }

/* ---------- Stats row (dashboard / resumen) ---------- */

.stat-row { display: flex; }

.stat-row .stat {
  flex: 1;
  padding: 0 10px;
  text-align: center;
  border-right: 0.5px solid var(--line-strong);
}

.stat-row .stat:first-child { padding-left: 0; text-align: left; }
.stat-row .stat:last-child { border-right: none; padding-right: 0; }
.stat-row.center .stat { text-align: center; }

.stat .value { font-size: 22px; margin: 0; }
.stat .label { color: var(--text-muted); font-size: 9px; margin: 4px 0 0; }

/* ---------- RPE selector ---------- */

.rpe-row { display: flex; gap: 2px; }

.rpe-cell {
  flex: 1;
  height: 30px;
  border-radius: 4px;
  border: 0.5px solid var(--line-strong);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
}

.rpe-cell.active { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }

/* ---------- Stepper (rondas +/-) ---------- */

.stepper { display: flex; align-items: center; gap: 6px; }

.stepper button {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 0.5px solid var(--line-strong);
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper .value { color: var(--text); font-size: 12px; font-weight: 500; min-width: 14px; text-align: center; }

/* ---------- Números grandes centrados (registrar peso, reps/kg) ---------- */

.center-number { text-align: center; }
.center-number .num { font-family: var(--font-display); font-size: 46px; font-weight: 600; }
.center-number .unit { font-size: 15px; color: var(--text-muted); margin-left: 5px; }

.split-number { display: flex; }
.split-number .part { flex: 1; text-align: center; border-right: 0.5px solid var(--line); }
.split-number .part:last-child { border-right: none; }
.split-number .part .num { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.split-number .part .lbl { color: var(--text-muted); font-size: 9px; margin: 2px 0 0; }

.big-number-input {
  width: 100%;
  background: none;
  border: none;
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.big-number-input::-webkit-outer-spin-button,
.big-number-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Calendario mensual ---------- */

.calendar-days-labels {
  display: flex;
  margin-bottom: 6px;
}
.calendar-days-labels span { flex: 1; text-align: center; color: var(--text-muted); font-size: 9px; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-cell {
  height: 26px;
  border-radius: 4px;
  background: var(--card);
}

.calendar-cell.trained { background: var(--accent); }
.calendar-cell.today { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.6); }
.calendar-cell.empty { background: var(--card-alt); }

/* ---------- Gráficas ---------- */

.chart-card { margin-bottom: 16px; }
.chart-card .chart-title { color: var(--text); font-size: 11px; margin: 0 0 10px; }
.chart-axis-labels { display: flex; justify-content: space-between; margin-top: 6px; }
.chart-axis-labels span { color: var(--text-muted); font-size: 8px; }

/* ---------- Bloques de rutina (crear / rutina de hoy) ---------- */

.bloque-card { margin-bottom: 10px; }
.bloque-card .bloque-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 9px;
}
.bloque-card .bloque-head .titulo { font-size: 12px; font-weight: 500; color: var(--text); }

.ejercicio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.ejercicio-row:first-of-type { margin-top: 0; }
.ejercicio-row .nombre { flex: 1; font-size: 11px; color: var(--text); }
.ejercicio-row .meta { color: var(--text-muted); font-size: 9px; }

/* ---------- Accesos rápidos (dashboard) ---------- */

.quick-links { display: flex; justify-content: space-around; margin-top: 22px; }
.quick-links a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 9px;
}
.quick-links .icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ---------- Estado vacío / error ---------- */

.empty-state { color: var(--text-muted); font-size: 12px; text-align: center; padding: 30px 10px; }

.error-banner {
  background: rgba(245, 71, 61, 0.12);
  border: 0.5px solid rgba(245, 71, 61, 0.4);
  color: #FF8A82;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.loading-state { color: var(--text-muted); font-size: 12px; text-align: center; padding: 30px 10px; }

/* ---------- Semana / horario ---------- */

.dia-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 0.5px solid var(--line);
}
.dia-row:last-child { border-bottom: none; }
.dia-row .dia-nombre { font-size: 12px; font-weight: 500; color: var(--text); width: 68px; flex-shrink: 0; }
.dia-row select {
  flex: 1;
  background: var(--card);
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 8px;
  outline: none;
}

/* ---------- Utilidades ---------- */

.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }
.mb-22 { margin-bottom: 22px; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.fs-9 { font-size: 9px; }
.fs-10 { font-size: 10px; }
.fs-11 { font-size: 11px; }
