/* ENTRENA — sistema visual claro "Trust Blue" (light, aireado, acento azul).
   Se conservan los nombres de variables que las vistas usan inline:
   --bg --panel --text --muted --accent --line */
:root {
    --bg:        #f4f7fc;          /* claro, tinte azul frío */
    --bg-2:      #eaf0f8;          /* inputs / placas */
    --panel:     #ffffff;          /* tarjetas */
    --panel-2:   #eef3fb;          /* hover */
    --glass:     rgba(255,255,255,.72);
    --text:      #0f1b2e;          /* azul pizarra profundo (no negro) */
    --muted:     #5f6b7d;
    --accent:    #2563eb;          /* azul confianza */
    --accent-2:  #3b82f6;
    --ink:       #ffffff;          /* texto sobre el acento */
    --line:      rgba(15,27,46,.10);
    --line-2:    rgba(15,27,46,.15);

    --radius:    26px;
    --radius-md: 18px;
    --radius-sm: 13px;

    --ease:      cubic-bezier(.32,.72,0,1);
    --ease-out:  cubic-bezier(.16,1,.3,1);

    --shadow:    0 24px 50px -28px rgba(30,52,98,.30);
    --glow:      0 12px 34px -12px rgba(37,99,235,.42);
    --ring:      0 0 0 4px rgba(37,99,235,.18);
    --hl:        inset 0 1px 0 rgba(255,255,255,.7);
    --maxw:      1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15.5px;
    line-height: 1.62;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100dvh;
}

/* Luz ambiental azul muy sutil detrás de todo */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(760px 520px at 84% -8%, rgba(37,99,235,.09), transparent 60%),
        radial-gradient(680px 520px at -6% 6%, rgba(56,130,246,.07), transparent 58%);
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; transition: color .35s var(--ease); }
a:hover { color: var(--accent-2); }
::selection { background: rgba(37,99,235,.20); }

/* ---------- Tipografía ---------- */
h1, h2, h3 {
    font-family: "Outfit", "Plus Jakarta Sans", sans-serif;
    color: var(--text);
    line-height: 1.08;
    letter-spacing: -0.035em;
    text-wrap: balance;
    margin: 0 0 .55em;
}
h1 { font-size: clamp(1.7rem, 1.15rem + 2.4vw, 2.55rem); font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.12rem; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.subtitle { color: var(--muted); font-size: 1.02rem; margin-top: -.25em; }
.label {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: "Outfit", sans-serif;
    text-transform: uppercase;
    letter-spacing: .22em;
    font-size: .66rem;
    font-weight: 600;
    color: var(--accent);
    padding: 5px 11px;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
code {
    font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
    font-size: .85em;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: .18em .48em;
}

/* ---------- Nav flotante de cristal (isla) ---------- */
.topbar {
    position: sticky;
    top: 16px;
    z-index: 40;
    width: min(var(--maxw), calc(100% - 32px));
    margin: 18px auto 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 9px 10px 9px 20px;
    background: var(--glass);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 20px 44px -26px rgba(30,52,98,.4), var(--hl);
}
.brand {
    font-family: "Outfit", sans-serif;
    font-weight: 800;
    letter-spacing: -0.04em;
    font-size: 19px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.brand::before {
    content: "";
    width: 12px; height: 12px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    box-shadow: 0 4px 12px rgba(37,99,235,.5);
}
.topbar nav { display: flex; align-items: center; gap: 3px; }
.topbar nav a {
    color: var(--muted);
    font-weight: 500;
    font-size: .93rem;
    padding: 8px 15px;
    border-radius: 999px;
    transition: color .35s var(--ease), background .35s var(--ease);
}
.topbar nav a:hover { color: var(--text); background: rgba(15,27,46,.05); }
.topbar nav a.active { color: var(--ink); background: linear-gradient(180deg, var(--accent-2), var(--accent)); font-weight: 600; }

/* ---------- Contenedor / ritmo espacial ---------- */
.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: clamp(34px, 6vw, 68px) clamp(18px, 4vw, 28px) 90px;
}
.container > h1 { margin-bottom: 22px; }

/* ---------- Botones isla (pill) ---------- */
.btn, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-family: "Outfit", sans-serif;
    font-weight: 600;
    font-size: .95rem;
    line-height: 1;
    padding: 13px 22px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform .5s var(--ease), box-shadow .5s var(--ease), background .5s var(--ease), border-color .5s var(--ease);
    will-change: transform;
}
.btn {
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    color: var(--ink);
    box-shadow: var(--glow), var(--hl);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -12px rgba(37,99,235,.5), var(--hl); color: var(--ink); }
.btn:active { transform: translateY(0) scale(.97); }
.btn .icon { transition: transform .5s var(--ease); }
.btn:hover .icon { transform: translateX(2px); }
.btn-secondary {
    background: var(--panel);
    color: var(--text);
    border-color: var(--line-2);
    box-shadow: 0 6px 18px -12px rgba(30,52,98,.4);
}
.btn-secondary:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2)); transform: translateY(-2px); }
.btn-secondary:active { transform: translateY(0) scale(.97); }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 18px; }
.field label, .field > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 500;
}
.field input,
input[type="text"], input[type="email"], input[type="password"], select {
    width: 100%;
    padding: 13px 15px;
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    transition: border-color .4s var(--ease), box-shadow .4s var(--ease), background .4s var(--ease);
}
.field input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field input:focus, input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--panel);
    box-shadow: var(--ring);
}
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }

/* ---------- Tarjetas ---------- */
.card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--hl), var(--shadow);
}
.card::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: calc(var(--radius) - 6px);
    border: 1px solid rgba(15,27,46,.04);
    pointer-events: none;
}

/* ---------- Alertas ---------- */
.error {
    background: #fdecec;
    color: #b42318;
    border: 1px solid rgba(180,35,24,.22);
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: .92rem;
}

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 14px 16px; }
th {
    font-family: "Outfit", sans-serif;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line); }
tbody tr { transition: background .3s var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td:last-child { font-weight: 500; }

/* ---------- Iconos (trazo fino) ---------- */
.icon { width: 18px; height: 18px; stroke-width: 1.5; }

/* ---------- Biblioteca de ejercicios ---------- */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }
.ex-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--hl), var(--shadow);
    transition: transform .55s var(--ease), border-color .55s var(--ease), box-shadow .55s var(--ease);
}
.ex-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line-2));
    box-shadow: 0 30px 54px -28px rgba(30,52,98,.4), var(--hl);
}
.ex-thumb {
    display: block;
    background: var(--bg-2);
    border-radius: calc(var(--radius-md) - 8px);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(15,27,46,.05);
}
.ex-thumb img { width: 100%; height: auto; display: block; transition: transform .6s var(--ease-out); }
.ex-card:hover .ex-thumb img { transform: scale(1.06); }
.ex-meta { display: block; padding: 11px 8px 6px; }
.ex-meta strong { font-size: 14px; display: block; letter-spacing: -0.01em; }
.ex-meta .muted { font-size: 12px; margin-top: 3px; display: block; }

.ex-detail-thumb {
    display: inline-block;
    background: var(--bg-2);
    padding: 10px;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(15,27,46,.06);
}
.ex-detail-thumb img { display: block; width: 100%; max-width: 200px; height: auto; border-radius: 12px; }

select { cursor: pointer; }

/* ---------- Cabecera de página ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Badges de estado ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: 999px;
    font-family: "Outfit", sans-serif;
    font-size: .74rem;
    font-weight: 600;
    border: 1px solid var(--line);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-ok { color: #15803d; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.28); }
.badge-pending { color: #b45309; background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.30); }

/* ---------- Filtros premium (biblioteca) ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search {
    flex: 1;
    min-width: 210px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--panel);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    padding: 11px 18px;
    box-shadow: 0 6px 18px -14px rgba(30,52,98,.4);
    transition: border-color .4s var(--ease), box-shadow .4s var(--ease);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search .icon { color: var(--muted); flex: 0 0 auto; }
.search input { border: 0; background: transparent; color: var(--text); width: 100%; outline: none; font: inherit; }
.filters select {
    width: auto;
    border-radius: 999px;
    padding: 12px 18px;
    background: var(--panel);
    border: 1px solid var(--line-2);
    color: var(--text);
    box-shadow: 0 6px 18px -14px rgba(30,52,98,.4);
}
.results-count { color: var(--muted); font-size: .88rem; margin: 0 0 20px; }
.results-count b { color: var(--text); font-family: "Outfit", sans-serif; }

/* ---------- Tiles de acción (dashboard) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 22px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    box-shadow: var(--hl), var(--shadow);
    transition: transform .5s var(--ease), border-color .5s var(--ease);
}
a.tile:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 30%, var(--line-2)); }
.tile .tile-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--accent); margin-bottom: 6px; }
.tile .tile-ico .icon { width: 20px; height: 20px; }
.tile strong { font-family: "Outfit", sans-serif; font-size: 1.05rem; letter-spacing: -.01em; }
.stat { font-family: "Outfit", sans-serif; font-weight: 700; font-size: 2.7rem; letter-spacing: -.035em; color: var(--text); line-height: 1; }

/* ---------- Estado vacío compuesto ---------- */
.empty { text-align: center; padding: 54px 24px; }
.empty .empty-ico { width: 62px; height: 62px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 20px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border: 1px solid var(--line); color: var(--accent); }
.empty .empty-ico .icon { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 42ch; }

/* Enlace de invitación */
.invite-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.invite-box code { flex: 1; min-width: 220px; word-break: break-all; padding: 11px 14px; background: var(--bg-2); }

/* Lista descriptiva (ficha) */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 22px; margin: 0; }
.dl dt { color: var(--muted); font-size: .84rem; }
.dl dd { margin: 0; }

/* Enlace "volver" */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.back-link:hover { color: var(--text); }

/* ---------- Revelado al hacer scroll (lo activa el JS del layout) ---------- */
.reveal { opacity: 0; transform: translateY(22px); filter: blur(6px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out), filter .8s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; filter: none; }

/* ---------- Scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Pie global discreto ---------- */
.site-footer {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 26px clamp(18px, 4vw, 28px) 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: .77rem;
    border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
.site-footer .dot { opacity: .5; }

@media (max-width: 620px) {
    .topbar { padding: 8px 8px 8px 16px; }
    .topbar nav a { padding: 7px 11px; }
    .card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; filter: none; }
}
