/* WebFit - estilo moderno (light + dark)
   Colores en variables para que puedas cambiarlos en 1 sitio.
*/

:root{
  --bg: #0b1020;
  --surface: rgba(255,255,255,0.06);
  --surface-2: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.68);
  --accent: #7c5cff;      /* morado azulado */
  --accent-2: #22c55e;    /* verde */
  --danger: #ef4444;
  --warn: #f59e0b;
  --shadow: 0 12px 40px rgba(0,0,0,0.35);
  --radius: 16px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(124,92,255,0.25);
}

@media (prefers-color-scheme: light){
  :root{
    --bg: #f6f7fb;
    --surface: rgba(255,255,255,0.75);
    --surface-2: rgba(255,255,255,0.95);
    --border: rgba(10,20,40,0.12);
    --text: rgba(10,20,40,0.92);
    --muted: rgba(10,20,40,0.62);
    --shadow: 0 14px 40px rgba(20,30,60,0.14);
    --focus: 0 0 0 4px rgba(124,92,255,0.18);
  }
}

*{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 15% -10%, rgba(124,92,255,0.35), transparent 55%),
    radial-gradient(900px 600px at 110% 10%, rgba(34,197,94,0.18), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(245,158,11,0.14), transparent 60%),
    var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.45;
}

a{ color: inherit; text-decoration: none; }

.container{
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

/* Topbar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), rgba(0,0,0,0.05));
  border-bottom: 1px solid var(--border);
}

@media (prefers-color-scheme: light){
  .topbar{ background: linear-gradient(to bottom, rgba(255,255,255,0.7), rgba(255,255,255,0.35)); }
}

.topbar-inner{
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.brand-mark{ font-size: 18px; }
.brand-name{ font-weight: 800; letter-spacing: 0.2px; }

.nav{
  display: flex;
  gap: 8px;
  margin-left: 4px;
  flex: 1;
}

.nav-link{
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-link:hover{
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.userbox{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

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

.page{ padding: 22px 0 40px 0; }

/* Utilities */
.stack{ display: grid; gap: 10px; }

.auth-card{
  width: min(520px, calc(100% - 32px));
  margin: 32px auto 0;
  padding: 24px 20px;
  background: rgba(52, 68, 102, 0.98) !important;
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}

.auth-card form{
  padding: 0 6px;
}

.auth-card input[type="text"],
.auth-card input[type="password"]{
  background: #fff;
  color: #111;
  border-color: rgba(0,0,0,0.08);
}

.auth-card input[type="text"]::placeholder,
.auth-card input[type="password"]::placeholder{
  color: rgba(0,0,0,0.45);
}

.auth-card .btn{
  background: linear-gradient(135deg, #2563eb, #1e40af);
  box-shadow: 0 8px 22px rgba(37,99,235,.35);
}

.alert{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.alert-danger{
  border-color: rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.12);
}

/* Headings */
h1,h2,h3{ margin: 0 0 14px 0; }

h2{ font-size: 1.35rem; }

p{ margin: 0 0 12px 0; color: var(--muted); }

/* Cards / blocks */
.card,
fieldset,
table{
  border-radius: var(--radius);
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Forms */
form{ margin: 0; }

fieldset{
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

legend{
  padding: 0 8px;
  color: var(--text);
  font-weight: 700;
}

label{ display: block; margin: 10px 0 6px; color: var(--muted); font-weight: 600; }

.auth-card label{ color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="number"],
select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

input[type="text"]::placeholder{ color: rgba(255,255,255,0.45); }

@media (prefers-color-scheme: light){
  input[type="text"]::placeholder{ color: rgba(10,20,40,0.35); }
}

input:focus, select:focus{ box-shadow: var(--focus); border-color: rgba(124,92,255,0.55); }

/* Buttons */
.btn,
.nav-btn,
.rutina-btn,
button{
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(124,92,255,1), rgba(34,197,94,0.9));
  color: white;
  box-shadow: 0 10px 28px rgba(124,92,255,0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover,
.nav-btn:hover,
.rutina-btn:hover,
button:hover{ filter: brightness(1.05); transform: translateY(-1px); }

.btn:active,
.nav-btn:active,
.rutina-btn:active,
button:active{ transform: translateY(0); }

.btn-ghost{
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.btn-ghost:hover{ background: var(--surface); }

.btn-danger{
  background: linear-gradient(135deg, rgba(239,68,68,1), rgba(245,158,11,0.95));
  box-shadow: 0 10px 28px rgba(239,68,68,0.22);
}

.btn-mini{
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
}

/* Month navigation */
.navegacion-mes-mejorada{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.titulo-mes h2{ margin: 0; }

.mes-espanol{
  margin: 4px 0 0 0;
  color: var(--muted);
  font-weight: 700;
}

/* Tables */
table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

thead th{
  text-align: center;
  padding: 12px 10px;
  color: var(--muted);
  font-weight: 900;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
}

@media (prefers-color-scheme: light){
  thead th{ background: rgba(10,20,40,0.03); }
}

tbody td{
  text-align: center;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

@media (prefers-color-scheme: light){
  tbody td{ border-bottom: 1px solid rgba(10,20,40,0.06); }
}

tbody tr:last-child td{ border-bottom: none; }

td a{ display: block; padding: 10px 6px; border-radius: 12px; color: var(--text); }

td a:hover{ background: rgba(124,92,255,0.16); }

/* Calendar states */
.hoy a{
  background: rgba(34,197,94,0.18);
  outline: 1px solid rgba(34,197,94,0.35);
  font-weight: 900;
}

.fuera{ opacity: 0.45; }

.km-hecho a{
  background: rgba(124,92,255,0.15);
  outline: 1px solid rgba(124,92,255,0.28);
}

/* Small helpers */
hr{
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

#autosave-msg{ color: var(--muted) !important; }

/* Mobile */
@media (max-width: 720px){
  .topbar-inner{ flex-wrap: wrap; }
  .nav{ width: 100%; order: 3; }
  .userbox{ width: 100%; justify-content: space-between; order: 4; }
  .navegacion-mes-mejorada{ flex-wrap: wrap; justify-content: center; text-align: center; }
  .dias-grid{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  legend{
    display: block;
    max-width: 100%;
    white-space: normal;
  }
  fieldset{
    overflow: visible;
  }
}

/* ✅ Fondo oscuro estable (evita bandas al hacer scroll) */
html, body{
  height: 100%;
  background: #0b1220;   /* color base sólido */
  margin: 0;
}

/* ✅ Pon el degradado como capa fija independiente (no en body background) */
body::before{
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;

  /* degradado suave */
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(99,102,241,.28), transparent 60%),
    radial-gradient(900px 500px at 90% 30%, rgba(16,185,129,.18), transparent 60%),
    radial-gradient(900px 500px at 50% 90%, rgba(236,72,153,.12), transparent 60%);
}

/* ✅ IMPORTANTE: si usabas background-attachment: fixed, lo anulamos */
body{
  background-attachment: scroll !important;
}

/* ✅ Si tienes contenedores "glass", que tengan fondo más sólido para que no se vea raro al scroll */
main, .container, .card, .panel{
  background: rgba(15, 23, 42, 0.88); /* más opaco */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ✅ Truco anti-seams en algunos navegadores */
body::before{
  transform: translateZ(0);
}

/* Chips días semana */
.dias-semana {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dias-grid{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dia-chip {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.55);
}

/* ✅ Seleccionado: muy visible */
.dia-chip.sel {
  background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(16,185,129,.85));
  border-color: rgba(255,255,255,.25);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
}

/* Opcional: hover */
.dia-chip:not(.sel):hover {
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.75);
}

/* Inputs de Series y Reps */
.input-series,
.input-reps {
  width: 70px;              /* 🔥 aquí controlas el ancho */
  min-width: 70px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;

  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 6px 8px;
}

/* Hover / focus */
.input-series:focus,
.input-reps:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,.35);
}

/* ===== Inputs numéricos base ===== */
.num-input{
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;

  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* ===== Anchos configurables ===== */
.w-series{
  width: 40px;       /* 👈 cambia aquí */
  min-width: 40px;
}

.w-reps{
  width: 120px;      /* 👈 cambia aquí */
  min-width: 120px;
}

/* (opcional) quitar flechas */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
input[type=number]{ -moz-appearance: textfield; }

/* ===== Fila añadir ejercicio: TODO en una sola línea ===== */
.fila-nuevo-ejercicio{
  display: grid;
  grid-template-columns:
    1fr          /* Nombre ejercicio */
    auto         /* Series */
    auto         /* Orden */
    auto         /* Reps */
    auto;        /* Botón */

  gap: 10px;
  align-items: center;
  margin-top: 1em;
}

/* Ajuste fino para el input de nombre */
.fila-nuevo-ejercicio input[type="text"]{
  min-width: 260px;
}

/* 📱 En móvil sí permitimos que baje */
@media (max-width: 640px){
  .fila-nuevo-ejercicio{
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }

  .fila-nuevo-ejercicio button{
    grid-column: span 4;
    justify-self: stretch;
  }
}

/* === Botón principal === */
.rutina-btn,
button{
  background: linear-gradient(135deg, #2563eb, #1e40af);
  box-shadow: 0 8px 22px rgba(37,99,235,.35);
  color: #fff;
}

/* Hover */
.rutina-btn:hover,
button:hover{
  filter: brightness(1.08);
}

/* Botón mini */
.btn-mini{
  background: linear-gradient(135deg, #2563eb, #1e40af);
  box-shadow: 0 6px 18px rgba(37,99,235,.30);
}

/* Botón borrar */
.btn-danger{
  background: linear-gradient(135deg, #dc2626, #991b1b);
  box-shadow: 0 6px 18px rgba(220,38,38,.35);
}
