﻿/* A-LAB â€” componentes base. Depende de tokens.css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* TipografÃ­a ------------------------------------------------ */
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.015em; line-height: 1.08; text-wrap: balance; }
.h1 { font-size: var(--fs-3xl); }
.h2 { font-size: var(--fs-2xl); }
.h3 { font-size: var(--fs-xl); font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* Botones --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); color: var(--ink-inverse); }
.btn--primary:hover { background: var(--brand-hover); color: var(--ink-inverse); }
.btn--primary:active { background: var(--brand-press); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--quiet { background: var(--brand-tint); color: var(--brand-ink); }
.btn--quiet:hover { background: var(--brand-tint-2); color: var(--brand-ink); }
.btn--danger { background: var(--surface); color: var(--bad); border-color: #E3B8B1; }
.btn--danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn--sm { height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--lg { height: 46px; padding: 0 22px; font-size: var(--fs-lg); }
.btn--block { width: 100%; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--brand); font-weight: 500; }

/* Campos ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.field__hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field__error { font-size: var(--fs-xs); color: var(--bad); display: flex; align-items: center; gap: 6px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(166, 60, 48, .14); }
.input[disabled] { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-group__btn { position: absolute; right: 4px; top: 4px; height: 32px; width: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); border-radius: var(--r-sm); cursor: pointer; }
.input-group__btn:hover { background: var(--surface-2); color: var(--ink); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; pointer-events: none; }
.input-icon .input { padding-left: 38px; }

.check { display: inline-flex; align-items: flex-start; gap: 10px; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; }
.check input { appearance: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; transition: background-color .15s, border-color .15s; }
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background-color .2s var(--ease); margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }

/* Segmentado / pestaÃ±as ------------------------------------- */
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; background: var(--surface-3); border-radius: var(--r-md); gap: 2px; }
.segmented button { height: 32px; padding: 0 16px; border: 0; background: transparent; color: var(--ink-2); font-weight: 500; font-size: var(--fs-md); border-radius: 4px; cursor: pointer; transition: background-color .15s, color .15s; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(17,28,22,.12); }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 0; color: var(--ink-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }

/* Etiquetas -------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip--pos { min-width: 36px; justify-content: center; font-family: var(--font-data); font-weight: 600; font-size: 11px; letter-spacing: .03em; }
.chip--gk { background: var(--pos-gk-bg); color: var(--pos-gk); }
.chip--def { background: var(--pos-def-bg); color: var(--pos-def); }
.chip--mid { background: var(--pos-mid-bg); color: var(--pos-mid); }
.chip--att { background: var(--pos-att-bg); color: var(--pos-att); }
.chip--ok { background: var(--ok-bg); color: var(--ok); }
.chip--warn { background: var(--warn-bg); color: var(--warn); }
.chip--danger { background: var(--bad-bg); color: var(--bad); }
.chip--info { background: var(--info-bg); color: var(--info); }
.chip--outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); }
.form { display: inline-flex; gap: 3px; }
.form i { width: 10px; height: 10px; border-radius: 2px; background: var(--res-draw); display: block; }
.form i[data-r="W"] { background: var(--res-win); }
.form i[data-r="L"] { background: var(--res-loss); }

/* Superficies ------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card__title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.005em; }
.card__sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }
.card__body { padding: 20px; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fs-md); border: 1px solid; }
.notice .icon { margin-top: 1px; }
.notice--info { background: var(--info-bg); border-color: #C5D8EA; color: #1F4669; }
.notice--ok { background: var(--ok-bg); border-color: #BCD8C6; color: var(--brand-ink); }
.notice--warn { background: var(--warn-bg); border-color: #E8D4A2; color: #6B4709; }
.notice--danger { background: var(--bad-bg); border-color: #E6BDB6; color: #7C2B22; }

.toast { display: inline-flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--ink); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-float); font-size: var(--fs-md); }
.toast .icon { color: #8FD0AE; }

/* Tablas ----------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #F7FAF8; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl .strong { font-weight: 600; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.entity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.entity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crest { width: 22px; height: 22px; object-fit: contain; flex: none; }
.crest--lg { width: 40px; height: 40px; }
.rank { font-family: var(--font-data); font-size: var(--fs-sm); color: var(--ink-3); width: 20px; display: inline-block; text-align: right; }
.rank--lead { color: var(--brand); font-weight: 600; }

.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint-2); color: var(--brand-ink); display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 600; flex: none; }

/* Layout de contenido (páginas migradas) ---------------------- */
.page { padding: 28px var(--gutter) 56px; display: flex; flex-direction: column; gap: 24px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-head__text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.hidden { display: none !important; }
.empty-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 20px; color: var(--ink-3); font-size: var(--fs-md); text-align: center; }
.empty-state .icon { color: var(--ink-3); }
@media (max-width: 1180px) { .col-4, .col-5, .col-7, .col-8 { grid-column: span 12; } }
@media (max-width: 760px) { .col-6 { grid-column: span 12; } }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand); animation: spin .7s linear infinite; vertical-align: -3px; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

/* Estado de carga compartido (ruedita + texto) ----------------
   Markup: <div class="al-cargando" role="status" aria-live="polite"><span class="spinner" aria-hidden="true"></span><span class="al-cargando__texto">Cargando estadísticas…</span></div>
   Lo arma window.ALAB_CARGA (public/js/alab-cargando.js). Aparece recién a los 250 ms (sin parpadeo si la carga es instantánea).
   Variantes: --fila (renglón compacto, para listas chicas y celdas) y --capa (aviso flotante sobre un bloque que ya tiene contenido). */
.al-cargando { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 96px; padding: 24px 16px; color: var(--ink-2); font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 500; text-align: center; }
.al-cargando .spinner { width: 26px; height: 26px; border-width: 3px; border-color: var(--brand-tint-2); border-top-color: var(--brand); }
.al-cargando--fila { flex-direction: row; min-height: 0; padding: 12px 8px; gap: 8px; }
.al-cargando--fila .spinner { width: 16px; height: 16px; border-width: 2px; }
.al-cargando--capa { position: absolute; z-index: 5; top: 12px; right: 12px; flex-direction: row; min-height: 0; gap: 8px; padding: 6px 12px 6px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-float); font-size: var(--fs-xs); }
.al-cargando--capa .spinner { width: 16px; height: 16px; border-width: 2px; }
.al-cargando-host { position: relative; }
.al-cargando-error { margin: 0; padding: 24px 16px; color: var(--ink-3); font-size: var(--fs-sm); text-align: center; }
/* Barra fina de progreso indeterminado arriba de la página (la maneja alab-cargando.js) */
.al-barra-carga { position: fixed; top: 0; left: 0; right: 0; z-index: 2147482000; height: 3px; overflow: hidden; background: var(--brand-tint); opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility 0s linear .2s; pointer-events: none; }
.al-barra-carga.is-on { opacity: 1; visibility: visible; transition: opacity .2s var(--ease); }
.al-barra-carga::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: var(--brand); border-radius: 0 2px 2px 0; }
@keyframes al-barra-corre { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes al-cargando-aparece { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .al-cargando { animation: al-cargando-aparece .2s var(--ease) .25s both; }
  .al-barra-carga::before { animation: al-barra-corre 1.2s var(--ease) infinite; }
}
/* Sin movimiento: sin ruedita ni barra que corre; queda el texto (y la barra quieta, apenas marcada). */
@media (prefers-reduced-motion: reduce) {
  .al-cargando .spinner { display: none; }
  .al-barra-carga::before { width: 100%; opacity: .35; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


