/* Sistema de diseño de RunnerPlanner, portado de globals.css de la landing (runnerplanner.com).
   Si cambias un token aquí, cámbialo también allí. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --text: #0f1729;
  --muted: #5d6578;
  --faint: #9aa3b5;
  --border: #e6e9f0;
  --blue: #1e4fd8;
  --blue-2: #2f6bf2;
  --cyan: #12b5e5;
  --gradient: linear-gradient(120deg, #1e4fd8 0%, #2f80ed 55%, #19c2f0 100%);
  --green-bg: #e7f8ee;
  --green: #1f9d55;
  --red-bg: #fdecec;
  --red: #d64545;
  --amber-bg: #fff4e0;
  --amber: #b7741a;
  --blue-bg: #e6eefe;
  --radius: 22px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
a { color: var(--blue); }
code { font-size: 0.9em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue-2) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.page { flex: 1; display: grid; gap: 18px; align-content: start; padding-top: 16px; padding-bottom: 40px; }

/* Cabecera */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.6rem; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.pill-tag { background: var(--surface); border-radius: 999px; padding: 10px 16px; font-size: 0.88rem; font-weight: 500; white-space: nowrap; }
@media (max-width: 480px) {
  .brand { font-size: 1.2rem; gap: 8px; }
  .brand svg { width: 28px; height: 28px; }
}

/* Tarjetas */
.panel { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgb(15 23 41 / 0.03); min-width: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 36px 32px; justify-items: start; }
.hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800; max-width: 22em; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 46em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
@media (max-width: 480px) {
  .hero { padding: 26px 20px; }
  .actions { width: 100%; }
  .actions > a { flex: 1 1 100%; white-space: normal; text-align: center; }
  .pill-tag { padding: 8px 12px; font-size: 0.8rem; }
}

.eyebrow { display: inline-block; background: var(--blue-bg); color: var(--blue); border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 600; }
.eyebrow.danger { background: var(--red-bg); color: var(--red); }

.badge { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }

/* Botones (micro-animación: elevación al pasar el ratón y pulsación al hacer clic) */
.btn-gradient, .btn-primary, .btn-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 0; border-radius: 999px; font: inherit; font-weight: 600; font-size: 0.92rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), filter 0.15s ease;
}
.btn-gradient { background: var(--gradient); color: #fff; padding: 11px 20px; box-shadow: 0 6px 16px rgb(30 79 216 / 0.28); }
.btn-primary { background: linear-gradient(120deg, #1e4fd8, #2f6bf2); color: #fff; padding: 11px 20px; }
.btn-light { background: var(--surface-2); color: var(--text); padding: 11px 22px; }
.btn-gradient:hover, .btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 10px 22px rgb(30 79 216 / 0.32); }
.btn-light:hover { transform: translateY(-1px); }
.btn-gradient:active, .btn-primary:active, .btn-light:active { transform: scale(0.98); }

/* Pasos */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; } }
.steps li { counter-increment: step; background: var(--surface); border-radius: var(--radius); padding: 20px; font-size: 0.92rem; color: var(--muted); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--gradient); color: #fff; font-weight: 700; margin-bottom: 10px; }
.steps strong { display: block; color: var(--text); margin-bottom: 4px; }

/* Pie */
.footer { padding: 28px 0 36px; font-size: 0.88rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* Skeleton: replica el layout real mientras cargan los datos (sin saltos de maquetación) */
.skeleton {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 0%, #e9edf5 40%, var(--surface-2) 80%);
  background-size: 300% 100%;
  animation: rp-shimmer 1.4s ease-in-out infinite;
}
@keyframes rp-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Entrada suave y escalonada: style="--i: 2" retrasa cada elemento */
.fade-up { animation: rp-fade-up 0.5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rp-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton { animation: none; background: var(--surface-2); }
}

/* Cabecera con sesión */
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu form { margin: 0; }
.user-menu .pill-tag { text-decoration: none; color: var(--text); transition: background 0.15s ease; }
.user-menu .pill-tag:hover { background: var(--surface-2); }
@media (max-width: 560px) { .user-menu .pill-tag:first-child:not(:last-of-type) { display: none; } }

/* Cabecera de página */
.page-head { padding: 8px 0 4px; }
.page-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; }
.page-sub { color: var(--muted); margin-top: 6px; }
.panel h2 { font-size: 1.15rem; margin-bottom: 4px; }
.panel-sub { color: var(--muted); font-size: 0.9rem; margin: 4px 0 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

/* Formularios */
.auth-card { width: 100%; max-width: 460px; margin: 12px auto 0; padding: 32px 30px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; }
@media (max-width: 480px) { .auth-card { padding: 26px 20px; } }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field input {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2);
  border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; min-height: 48px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.field input:hover { background: #eef1f7; }
.field input:focus { outline: none; background: var(--surface); border-color: var(--blue-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-2) 15%, transparent); }
.field input.invalid { border-color: var(--red); }
.field input:disabled { opacity: 0.6; }
.field-help { color: var(--faint); font-size: 0.82rem; }
.field-error, .validation-message { color: var(--red); font-size: 0.84rem; font-weight: 500; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.auth-links { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.form button[type="submit"] { width: 100%; }
.settings-grid .form button[type="submit"] { width: auto; justify-self: start; }

/* Avisos (con entrada suave) */
.alert { margin: 0; padding: 12px 16px; border-radius: 14px; font-size: 0.92rem; animation: rp-fade-up 0.3s var(--ease-out) both; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.success { background: var(--green-bg); color: var(--green); }
ul.alert { padding-left: 32px; }
.alert p + p { margin-top: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; word-break: break-all; color: var(--text); }
.empty { color: var(--muted); padding: 18px 0; }

/* Botones de texto y estado de carga */
.link-button { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--blue); cursor: pointer; }
.link-button.danger { color: var(--red); }
.link-button:disabled { opacity: 0.5; cursor: default; }
.btn-gradient:disabled, .btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }
.spinner { width: 14px; height: 14px; border: 2px solid rgb(255 255 255 / 0.4); border-top-color: #fff; border-radius: 50%; animation: rp-spin 0.7s linear infinite; }
@keyframes rp-spin { to { transform: rotate(360deg); } }

/* Tabla, barra de progreso y skeleton de filas */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { background: var(--surface-2); text-align: left; font-weight: 500; color: #333b4d; padding: 12px 14px; white-space: nowrap; }
.table th:first-child { border-radius: 12px 0 0 12px; }
.table th:last-child { border-radius: 0 12px 12px 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 14px; justify-content: flex-end; }
.row-in { animation: rp-fade-up 0.35s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; background: var(--gradient); border-radius: 999px; transition: width 0.3s var(--ease-out); }
.skeleton-table { display: grid; gap: 14px; padding: 6px 0; }
.skeleton-row { display: flex; gap: 18px; }
.skeleton-row .skeleton { height: 16px; }

/* Ajustes finos */
.auth-card > .eyebrow, .hero > .eyebrow { justify-self: start; }
.badge + .badge, td .badge { margin-left: 6px; }
input[type="file"] { font: inherit; font-size: 0.88rem; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.88rem; margin-right: 12px; border: 0; border-radius: 999px;
  padding: 10px 18px; background: var(--blue-bg); color: var(--blue); cursor: pointer; transition: filter 0.15s ease;
}
input[type="file"]::file-selector-button:hover { filter: brightness(0.97); }
