/* =========================================================================
   MiCuota - sistema visual (mc.css)
   Tokens + componentes compartidos por landing, cuenta, app y pagina de pago.
   Mobile-first, modo claro/oscuro, contraste WCAG AA, texto base 18px.
   Las paginas secundarias (backoffice, alumno, admin) siguen usando ui.css.
   ========================================================================= */

:root {
  color-scheme: light;
  /* Color */
  --bg: #f7f5ef;
  --bg-soft: #efece3;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --text: #17201c;
  --text-muted: #4f5b55;
  --border: #d9d5c9;
  --border-strong: #a8a397;

  --brand: #0b6b4d;          /* verde mate: 6.6:1 con blanco */
  --brand-hover: #08573e;
  --brand-soft: #e2f1ea;
  --on-brand: #ffffff;

  --mp: #005fa3;             /* azul Mercado Pago accesible (6.4:1 con blanco) */
  --mp-hover: #004c83;
  --on-mp: #ffffff;

  --ok: #0a6b3a;  --ok-soft: #dff3e6;
  --warn: #7a4b00; --warn-soft: #fdf0cf;
  --late: #a1260f; --late-soft: #fde4dc;
  --info: #1f4e8c; --info-soft: #e1ebf8;

  --focus: #1a5fd6;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 8px 24px rgba(20, 30, 25, .07);
  --shadow-lg: 0 2px 6px rgba(20, 30, 25, .08), 0 24px 48px rgba(20, 30, 25, .12);

  /* Tipografia */
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
  --fs-xs: .875rem;
  --fs-sm: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: clamp(2rem, 6vw, 2.75rem);
  --fs-3xl: clamp(2.4rem, 8vw, 4rem);

  /* Espaciado y forma */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --tap: 52px;               /* alto minimo de botones */
  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101513; --bg-soft: #161d1a; --surface: #1a2320; --surface-2: #202b27;
    --text: #eef3f0; --text-muted: #b2bfb8; --border: #33413b; --border-strong: #55655d;
    --brand: #4cc795; --brand-hover: #6fd7aa; --brand-soft: #173a2d; --on-brand: #06231a;
    --mp: #5fb4f0; --mp-hover: #86c7f5; --on-mp: #04243b;
    --ok: #6ad69b; --ok-soft: #173826; --warn: #f1c056; --warn-soft: #3a2d10;
    --late: #ff9a85; --late-soft: #44201a; --info: #9cc2f5; --info-soft: #1b2b44;
    --focus: #8fb8ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 24px 48px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513; --bg-soft: #161d1a; --surface: #1a2320; --surface-2: #202b27;
  --text: #eef3f0; --text-muted: #b2bfb8; --border: #33413b; --border-strong: #55655d;
  --brand: #4cc795; --brand-hover: #6fd7aa; --brand-soft: #173a2d; --on-brand: #06231a;
  --mp: #5fb4f0; --mp-hover: #86c7f5; --on-mp: #04243b;
  --ok: #6ad69b; --ok-soft: #173826; --warn: #f1c056; --warn-soft: #3a2d10;
  --late: #ff9a85; --late-soft: #44201a; --info: #9cc2f5; --info-soft: #1b2b44;
  --focus: #8fb8ff;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 24px 48px rgba(0,0,0,.45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -.015em; margin: 0 0 var(--s-3); }
h1 { font-size: var(--fs-2xl); font-weight: 750; }
h2 { font-size: var(--fs-xl); font-weight: 700; }
h3 { font-size: var(--fs-lg); font-weight: 700; }
p { margin: 0 0 var(--s-3); }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }
strong { font-weight: 700; }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--s-4); }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: var(--r-sm); z-index: 100; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s-4); }
.narrow { max-width: 560px; margin: 0 auto; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-display); font-weight: 750; font-size: 1.3rem; letter-spacing: -.02em; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand:hover { color: var(--text); }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 12px 22px;
  border-radius: var(--r-md); border: 2px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 700 var(--fs-md)/1.2 var(--font-body);
  text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { color: var(--btn-fg); border-color: var(--text-muted); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--on-brand); --btn-bd: var(--brand); }
.btn-primary:hover { --btn-bg: var(--brand-hover); border-color: var(--brand-hover); }
.btn-mp { --btn-bg: var(--mp); --btn-fg: var(--on-mp); --btn-bd: var(--mp); }
.btn-mp:hover { --btn-bg: var(--mp-hover); border-color: var(--mp-hover); }
.btn-wa { --btn-bg: #146c3f; --btn-fg: #fff; --btn-bd: #146c3f; }
.btn-wa:hover { --btn-bg: #0f5631; border-color: #0f5631; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--brand); }
.btn-ghost:hover { --btn-bg: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-danger { --btn-fg: var(--late); }
.btn-lg { min-height: 60px; font-size: 1.2rem; padding: 14px 26px; border-radius: var(--r-lg); }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn .spinner { width: 20px; height: 20px; }

/* ---------- Tarjetas y superficies ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.card + .card { margin-top: var(--s-4); }
.card-title { font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s-4); }
.field > label, .label { font-weight: 700; font-size: var(--fs-md); }
.hint { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: 400 var(--fs-md)/1.3 var(--font-body); color: var(--text);
  background: var(--surface); border: 2px solid var(--border-strong); border-radius: var(--r-md);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--late); }
.input-money { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -2px; }
.prefix-group { position: relative; }
.prefix-group .prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--text-muted); pointer-events: none; }
.prefix-group .input { padding-left: 64px; }
.field-error { color: var(--late); font-weight: 700; font-size: var(--fs-sm); margin: 0; }

/* Selector grande (radio en forma de tarjeta) */
.choice-group { display: grid; gap: var(--s-3); border: 0; padding: 0; margin: 0 0 var(--s-4); }
.choice-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.choice-grid-2 { grid-template-columns: 1fr 1fr; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice .choice-box { display: block; border: 2px solid var(--border-strong); border-radius: var(--r-md); padding: 14px 16px; background: var(--surface); min-height: var(--tap); }
.choice .choice-box strong { display: block; }
.choice .choice-box span { color: var(--text-muted); font-size: var(--fs-sm); }
.choice input:checked + .choice-box { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice input:focus-visible + .choice-box { outline: 3px solid var(--focus); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 44px; padding: 8px 14px; border-radius: var(--r-pill); border: 2px solid var(--border); background: var(--surface); color: var(--text); font: 700 var(--fs-sm)/1 var(--font-body); cursor: pointer; }
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Estados ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; }
.pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-late { background: var(--late-soft); color: var(--late); }
.pill-info { background: var(--info-soft); color: var(--info); }

.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); }
.notice svg { flex: none; width: 24px; height: 24px; margin-top: 2px; }
.notice p:last-child { margin-bottom: 0; }
.notice-ok { background: var(--ok-soft); border-color: transparent; color: var(--text); }
.notice-ok svg { color: var(--ok); }
.notice-warn { background: var(--warn-soft); border-color: transparent; }
.notice-warn svg { color: var(--warn); }
.notice-late { background: var(--late-soft); border-color: transparent; }
.notice-late svg { color: var(--late); }
.notice-info { background: var(--info-soft); border-color: transparent; }
.notice-info svg { color: var(--info); }

/* ---------- Carga ---------- */
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: mc-spin .8s linear infinite; display: inline-block; }
@keyframes mc-spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg-soft), var(--surface-2), var(--bg-soft)); background-size: 200% 100%; animation: mc-shimmer 1.4s ease-in-out infinite; border-radius: var(--r-sm); min-height: 1em; }
@keyframes mc-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Aviso global "despertando el servidor" */
.wake-banner { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; width: min(560px, calc(100% - 32px)); background: var(--text); color: var(--bg); border-radius: var(--r-md); padding: 14px 18px; box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; font-size: var(--fs-sm); }
.wake-banner .spinner { width: 22px; height: 22px; flex: none; }
.wake-banner strong { display: block; font-size: var(--fs-md); }
.has-tabbar .wake-banner { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Toast */
.toast-region { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 95; display: grid; gap: 8px; width: min(480px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 14px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-weight: 700; animation: mc-in .2s ease-out; pointer-events: auto; }
.toast.is-error { background: var(--late); color: #fff; }
@keyframes mc-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--brand-soft); color: var(--brand); font-size: 1.05rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.amount { font-family: var(--font-display); font-weight: 750; letter-spacing: -.02em; white-space: nowrap; }

.empty { text-align: center; padding: var(--s-6) var(--s-4); }
.empty .empty-icon { width: 64px; height: 64px; margin: 0 auto var(--s-4); border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty .empty-icon svg { width: 32px; height: 32px; }

/* ---------- Dialog ---------- */
dialog.sheet { border: 0; padding: 0; background: transparent; max-width: 520px; width: calc(100% - 24px); color: var(--text); }
dialog.sheet::backdrop { background: rgba(10, 16, 13, .55); }
dialog.sheet .sheet-body { background: var(--surface); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-lg); }
.qr-box { background: #fff; padding: 16px; border-radius: var(--r-md); width: min(280px, 100%); margin: 0 auto; border: 1px solid var(--border); }
.qr-box svg { width: 100%; height: auto; }

/* ---------- Utilidades de movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .no-print, .wake-banner, .toast-region { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; }
}
