/* Dynaro · estilo global. Paleta "Atardecer": azul noche, coral suave y arena. */
:root {
  color-scheme: dark;
  --primary: #ff8a6b;
  --primary-dark: #f0765a;
  --primary-light: rgba(255, 138, 107, 0.12);
  --on-primary: #2a0f08;
  --accent: #f4c98b;
  --accent-light: rgba(244, 201, 139, 0.12);
  --danger-light: rgba(242, 102, 122, 0.14);
  --bg: #0f1220;
  --surface: #171b2e;
  --surface-2: #1e2338;
  --border: #2a2f4a;
  --text: #f3ede4;
  --text-muted: #9a9db5;
  --error: #f2667a;
  --success: #5fd0a0;
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

.oculto {
  display: none;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.pantalla {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
}

/* Marca: logo de la app sobre las pantallas de acceso */
.marca-logo {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 14px;
}

.logo-circulo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 26px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 4px;
}

.subtitulo {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 15px;
  background: var(--surface-2);
  color: var(--text);
  color-scheme: dark;
  font-family: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* Safari (iOS) calcula un ancho mínimo interno para el control de fecha según
   su contenido (día/mes/año) que puede ser mayor que el ancho por CSS, y deja
   que el control se salga de su contenedor en vez de encogerlo. Forzar el
   min-width lógico de WebKit a 0 es el arreglo documentado para ese bug. */
input[type="date"] {
  -webkit-min-logical-width: 0%;
}

/* En iOS Safari el campo de fecha tiene aspecto nativo propio: se sale de su
   tarjeta, es más alto que los demás y centra el texto. Con appearance:none se
   comporta como un campo normal, alineado a la izquierda. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 46px;
  line-height: normal;
  text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.2em;
  margin: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  border-width: 2px;
  padding: 11px 13px;
}

button {
  width: 100%;
  padding: 14px;
  margin-top: 24px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button:active:not(:disabled) {
  background: var(--primary-dark);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.secundario {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 8px;
  font-weight: 500;
}

.error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

.enlace-inferior {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.enlace-inferior a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

/* Páginas con contenido largo (perfil, rutina, etc.), no un único card centrado */
.pagina {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 110px;
}

.cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.cabecera a {
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cabecera h1 {
  margin: 0;
  text-align: left;
  font-size: 21px;
}

.seccion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.seccion h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--text);
}

.fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.fila:last-child {
  border-bottom: none;
}

.fila strong {
  color: var(--primary);
  font-weight: 600;
}

.exito {
  color: var(--success);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

.fila-doble {
  display: flex;
  gap: 12px;
}

.fila-doble > * {
  flex: 1;
  min-width: 0;
}

.fila-doble input,
.fila-doble select {
  width: 100%;
  min-width: 0;
}

/* Cajas de aviso / éxito dentro de contenido generado dinámicamente */
.caja-aviso {
  background: var(--accent-light);
  border: 1px solid rgba(244, 201, 139, 0.3);
}

.caja-aviso h2 {
  color: var(--accent);
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

.pill-info {
  width: auto;
  margin: 0;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
}

/* Selector visual de equipamiento (tarjetas con foto), usado en gimnasio.html
   y en el paso de gimnasio del asistente de bienvenida. */
.grid-equipos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.tarjeta-equipo {
  position: relative;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s;
}

.tarjeta-equipo.seleccionada {
  border-color: var(--primary);
}

.tarjeta-equipo .equipo-imagen {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
  background: var(--surface);
}

.tarjeta-equipo .equipo-icono {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--surface);
}

.tarjeta-equipo .equipo-nombre {
  font-size: 11px;
  font-weight: 600;
  padding: 8px 6px;
  line-height: 1.25;
}

.tarjeta-equipo .equipo-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: transparent;
}

.tarjeta-equipo.seleccionada .equipo-check {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* Navegación inferior fija (5 pantallas principales) */
.nav-inferior {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 500;
}

.nav-inferior a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 500;
  padding: 4px 0;
  max-width: 90px;
  margin: 0 auto;
}

.nav-inferior a.activo {
  color: var(--primary);
}

.nav-inferior .nav-icono {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
}

/* Tarjetas de estadística estilo "stat tile" (inicio) */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}

.stat-tile .stat-valor {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: block;
  margin-bottom: 2px;
}

.stat-tile .stat-etiqueta {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Fila de una serie en modo entreno: 2 líneas fijas (número+kg+reps arriba,
   registrar+borrar abajo) para que quepa bien en pantallas estrechas. */
.fila-serie {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.fila-serie:last-child {
  border-bottom: none;
}

.fila-serie-arriba {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.fila-serie-arriba input {
  width: 0;
  flex: 1;
  padding: 10px 8px;
}

.fila-serie-abajo {
  display: flex;
  gap: 8px;
}

.fila-serie-abajo .btn-registrar-serie {
  flex: 1;
  margin: 0;
  padding: 10px;
  font-size: 13px;
}

.fila-serie-abajo .btn-eliminar-serie {
  width: 44px;
  flex: none;
  margin: 0;
  padding: 10px;
  background: var(--danger-light);
  color: var(--error);
}

/* Iconos de línea sueltos dentro de textos y botones (sustituyen a los emojis) */
.ico-inline {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
  margin-right: 5px;
  flex: none;
}

.logo-circulo .ico-inline {
  width: 28px;
  height: 28px;
  margin: 0;
  vertical-align: baseline;
}

.equipo-icono {
  color: var(--text-muted);
}

.equipo-icono .ico-inline {
  width: 28px;
  height: 28px;
  margin: 0;
}

/* Ajustes para móviles estrechos (~360px e inferior) */
@media (max-width: 380px) {
  .pagina {
    padding-left: 12px;
    padding-right: 12px;
  }

  .seccion {
    padding: 16px;
  }

  .nav-inferior a {
    font-size: 10px;
  }

  .stat-tile {
    padding: 10px 6px;
  }

  .stat-tile .stat-valor {
    font-size: 19px;
  }

  .fila-doble {
    gap: 8px;
  }

  input,
  select,
  textarea {
    font-size: 14px;
    padding: 11px 10px;
  }

  input[type="date"] {
    padding-right: 4px;
    font-size: 13px;
  }

  label {
    font-size: 12px;
  }
}
