/* auth.css — Login, registro y recuperación de Robi.
   Evolución de register-styles.css: mismo layout partido (formulario + panel de bienvenida),
   con los tokens --rb-* del tablero, DM Sans autohospedada, modo oscuro y estados accesibles. */

@font-face {
  font-family: "DM Sans";
  src: url("../assets/fonts/dm-sans/DMSans-var-latin.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans";
  src: url("../assets/fonts/dm-sans/DM-Sans-Regular-ext.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --rb-primary: #3B82F6;
  --rb-primary-strong: #2563EB;
  --rb-primary-press: #1D4ED8;
  --rb-primary-text: #2563EB;
  --rb-on-primary: #FFFFFF;
  --rb-primary-container: #DBEAFE;
  --rb-bg: #F1F5F9;
  --rb-surface: #FFFFFF;
  --rb-surface-variant: #F8FAFC;
  --rb-text: #0F172A;
  --rb-text-2: #334155;
  --rb-muted: #64748B;
  --rb-muted-strong: #526077;
  --rb-outline: #CBD5E1;
  --rb-outline-variant: #E2E8F0;
  --rb-pos-fg: #15803D;
  --rb-pos-bg: #F0FDF4;
  --rb-pos-line: #86EFAC;
  --rb-neg-fg: #B91C1C;
  --rb-neg-bg: #FEF2F2;
  --rb-neg-line: #FCA5A5;
  --rb-neg-input: #DC2626;
  --rb-info-fg: #1E40AF;
  --rb-info-bg: #EFF6FF;
  --rb-info-line: #93C5FD;
  --rb-warn: #B45309;
  --rb-hero-a: #1E3A5F;
  --rb-hero-b: #2563EB;
  --rb-shadow-card: 0 1px 2px rgba(15, 23, 42, .06), 0 24px 48px -16px rgba(15, 23, 42, .18);
  --rb-ring: 0 0 0 2px var(--rb-surface), 0 0 0 4px var(--rb-primary-strong);
  --rb-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px;
  --field: 48px;
  --radius-field: 12px;
  --radius-btn: 14px;
  --radius-card: 20px;
  --dur-1: 100ms;
  --dur-2: 150ms;
  --dur-3: 200ms;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

html.dark {
  color-scheme: dark;
  --rb-bg: #0F172A;
  --rb-surface: #1E293B;
  --rb-surface-variant: #172033;
  --rb-text: #F1F5F9;
  --rb-text-2: #CBD5E1;
  --rb-muted: #A3B1C6;
  --rb-muted-strong: #A3B1C6;
  --rb-outline: #475569;
  --rb-outline-variant: #334155;
  --rb-primary-text: #93C5FD;
  --rb-primary-container: #1E3A5F;
  --rb-pos-fg: #8FCC9E;
  --rb-pos-bg: #1A3D2E;
  --rb-pos-line: #2F6B4A;
  --rb-neg-fg: #F0B0B0;
  --rb-neg-bg: #3A2528;
  --rb-neg-line: #7F3A3F;
  --rb-neg-input: #F87171;
  --rb-info-fg: #BFDBFE;
  --rb-info-bg: #172554;
  --rb-info-line: #1E40AF;
  --rb-warn: #FBBF24;
  --rb-hero-a: #0B1324;
  --rb-hero-b: #1E3A8A;
  --rb-shadow-card: 0 0 0 1px rgba(255, 255, 255, .05), 0 24px 48px -16px rgba(0, 0, 0, .6);
  --rb-ring: 0 0 0 2px var(--rb-surface), 0 0 0 4px #93C5FD;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--rb-bg);
  color: var(--rb-text);
  font-family: var(--rb-font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.auth h1, .auth h2, .auth p { margin: 0; }
.auth a { color: var(--rb-primary-text); text-underline-offset: 3px; }
.auth :focus { outline: none; }
.auth :focus-visible { outline: none; box-shadow: var(--rb-ring); }
.sr-only { position: absolute !important; 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; z-index: 10; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; text-decoration: none; border-radius: 10px; background: var(--rb-surface); color: var(--rb-text); font-weight: 600; }
.skip-link:focus-visible { top: 12px; }

/* ── Tarjeta partida (misma estructura que antes) ── */
.container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  max-width: 1040px;
  min-height: min(680px, calc(100dvh - 48px));
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--rb-surface);
  box-shadow: var(--rb-shadow-card);
}

.register-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(28px, 5vw, 64px);
  background: var(--rb-surface);
}
.auth-inner { width: 100%; max-width: 380px; margin: 0 auto; }

.auth .brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--rb-text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .2px; min-height: var(--tap); border-radius: 10px; }
.brand img { width: 36px; height: 36px; display: block; }
.brand .brand-dark { display: none; }
html.dark .brand .brand-light { display: none; }
html.dark .brand .brand-dark { display: block; }

.title { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.3px; color: var(--rb-text); }
.subtitle { margin-top: 6px !important; color: var(--rb-muted); font-size: 15px; }
.auth-head { margin-bottom: 24px; }

/* ── Formulario ── */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--rb-text-2); }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.control { position: relative; }
.input {
  width: 100%;
  height: var(--field);
  padding: 0 14px;
  border: 1px solid var(--rb-outline);
  border-radius: var(--radius-field);
  background: var(--rb-surface-variant);
  color: var(--rb-text);
  font: inherit;
  font-size: 16px; /* evita el zoom de iOS */
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.input::placeholder { color: var(--rb-muted); opacity: 1; }
.input:hover { border-color: var(--rb-muted); }
.input:focus-visible, .input:focus { border-color: var(--rb-primary-strong); background: var(--rb-surface); box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); }
html.dark .input:focus-visible, html.dark .input:focus { box-shadow: 0 0 0 3px rgba(147, 197, 253, .28); }
.input[aria-invalid="true"] { border-color: var(--rb-neg-input); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .2); }
.control.has-toggle .input { padding-right: 52px; }
.input:-webkit-autofill { -webkit-text-fill-color: var(--rb-text); box-shadow: 0 0 0 100px var(--rb-surface-variant) inset; caret-color: var(--rb-text); }

.pw-toggle {
  position: absolute; top: 2px; right: 2px;
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--rb-muted); cursor: pointer;
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.pw-toggle:hover { color: var(--rb-text); background: var(--rb-outline-variant); }
.pw-toggle svg { width: 20px; height: 20px; }
.pw-toggle .ico-hide { display: none; }
.pw-toggle[aria-pressed="true"] .ico-show { display: none; }
.pw-toggle[aria-pressed="true"] .ico-hide { display: block; }

.field-hint { font-size: 13px; color: var(--rb-muted); }
.field-error { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; font-weight: 500; color: var(--rb-neg-fg); }
.field-error::before { content: ""; flex: 0 0 14px; height: 14px; margin-top: 2px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center/contain no-repeat; }
.field-error[hidden], .caps-hint[hidden] { display: none; }
.caps-hint { font-size: 13px; color: var(--rb-warn); font-weight: 500; }

/* Requisitos de contraseña */
.pw-rules { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 13px; color: var(--rb-muted); }
.pw-rules li { display: flex; align-items: center; gap: 6px; min-height: 22px; transition: color var(--dur-2) var(--ease); }
.pw-rules li::before { content: ""; width: 14px; height: 14px; flex: 0 0 14px; border-radius: 50%; border: 1.5px solid currentColor; transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease); }
.pw-rules li.ok { color: var(--rb-pos-fg); }
.pw-rules li.ok::before { border-color: transparent; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm-1.5 14.5-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7Z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm-1.5 14.5-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7Z'/%3E%3C/svg%3E") center/contain no-repeat; }
.pw-rules.show-missing li:not(.ok) { color: var(--rb-neg-fg); }

/* Checkbox con área táctil de 44px */
.check { display: flex; align-items: flex-start; gap: 10px; min-height: var(--tap); padding: 10px 0; cursor: pointer; font-size: 14px; color: var(--rb-text-2); line-height: 1.45; }
.check input { appearance: none; -webkit-appearance: none; flex: 0 0 22px; width: 22px; height: 22px; margin: 0; border: 1.5px solid var(--rb-outline); border-radius: 6px; background: var(--rb-surface); cursor: pointer; display: grid; place-items: center; transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease); }
.check input::after { content: ""; width: 12px; height: 12px; background: var(--rb-on-primary); transform: scale(0); transition: transform var(--dur-2) var(--ease); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center/contain no-repeat; }
.check input:checked { background: var(--rb-primary-strong); border-color: var(--rb-primary-strong); }
.check input:checked::after { transform: scale(1); }
.check input[aria-invalid="true"] { border-color: var(--rb-neg-input); }
.check.compact { padding: 0; align-items: center; }
.check a { font-weight: 600; }
.checks { display: flex; flex-direction: column; gap: 0; }
.checks .field-error { margin: -4px 0 4px 32px; }

.remember-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: -4px; }
.link-tap { display: inline-flex; align-items: center; min-height: var(--tap); font-size: 14px; font-weight: 600; text-decoration: none; border-radius: 8px; }
.link-tap:hover { text-decoration: underline; }

/* ── Botones ── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: var(--field);
  padding: 0 20px;
  border: 0; border-radius: var(--radius-btn);
  font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background-color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--rb-primary-strong); color: var(--rb-on-primary); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.btn-primary:hover { background: var(--rb-primary-press); }
.auth a.btn-primary, .auth a.btn-primary:hover { color: var(--rb-on-primary); }
.auth a.btn-secondary { color: var(--rb-text); }
.btn-primary:active { transform: scale(.985); }
.btn-primary[disabled] { cursor: progress; background: var(--rb-primary-press); }
.btn-secondary { background: transparent; color: var(--rb-text); border: 1px solid var(--rb-outline); }
.btn-secondary:hover { background: var(--rb-outline-variant); }
.btn-secondary[disabled] { cursor: not-allowed; color: var(--rb-muted); }
.btn .spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: rb-spin .7s linear infinite; }
.btn[aria-busy="true"] .spinner { display: inline-block; }
.btn.is-success { background: #15803D; }
@keyframes rb-spin { to { transform: rotate(360deg); } }

.divider { display: flex; align-items: center; gap: 12px; color: var(--rb-muted); font-size: 13px; margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rb-outline-variant); }

.google-slot { display: flex; justify-content: center; min-height: 44px; width: 100%; }
.google-slot > div { max-width: 100%; }
.google-note { font-size: 13px; color: var(--rb-muted); text-align: center; }

.switch { text-align: center; font-size: 15px; color: var(--rb-muted); margin-top: 4px !important; }
.switch a { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 4px; border-radius: 8px; }
.switch a:hover { text-decoration: underline; }
.back-link { display: inline-flex; align-items: center; gap: 6px; justify-content: center; }

/* ── Alertas ── */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: 14px; line-height: 1.45; margin-bottom: 16px; animation: rb-in var(--dur-3) var(--ease); }
.alert[hidden] { display: none; }
.alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.alert .alert-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.alert .alert-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.alert .alert-actions a { display: inline-flex; align-items: center; min-height: 32px; font-weight: 600; color: inherit; text-decoration: underline; }
.alert.error { background: var(--rb-neg-bg); border-color: var(--rb-neg-line); color: var(--rb-neg-fg); }
.alert.success { background: var(--rb-pos-bg); border-color: var(--rb-pos-line); color: var(--rb-pos-fg); }
.alert.info { background: var(--rb-info-bg); border-color: var(--rb-info-line); color: var(--rb-info-fg); }
@keyframes rb-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Contenedores que reciben foco por script (para lectores de pantalla): sin anillo */
.auth .done-state:focus-visible, .auth .alert:focus-visible { box-shadow: none; }

/* Estado "revisá tu email" */
.done-state { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.done-state[hidden] { display: none; }
.done-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--rb-primary-container); color: var(--rb-primary-text); }
.done-icon svg { width: 28px; height: 28px; }
.done-state .muted { color: var(--rb-muted); }

/* ── Panel de bienvenida (derecha) ── */
.welcome-panel {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 16px;
  padding: 56px 48px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, var(--rb-hero-a) 0%, var(--rb-hero-b) 100%);
  overflow: hidden;
  isolation: isolate;
}
.welcome-panel::before, .welcome-panel::after { content: ""; position: absolute; border-radius: 50%; z-index: -1; pointer-events: none; }
.welcome-panel::before { width: 420px; height: 420px; right: -160px; top: -140px; background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 70%); }
.welcome-panel::after { width: 360px; height: 360px; left: -140px; bottom: -160px; background: radial-gradient(circle, rgba(147, 197, 253, .22), transparent 70%); }
.welcome-icon { width: 80px; height: 80px; border-radius: 24px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); }
.welcome-icon svg { width: 40px; height: 40px; fill: #fff; }
.welcome-panel h2 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.2px; color: #fff; }
.welcome-panel p { margin-top: 8px !important; max-width: 34ch; font-size: 16px; line-height: 1.6; color: rgba(255, 255, 255, .92); }
.login-cta { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); margin-top: 8px; padding: 0 22px; border: 1.5px solid rgba(255, 255, 255, .85); border-radius: 999px; color: #fff !important; font-weight: 600; font-size: 15px; text-decoration: none; transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease); }
.login-cta svg { width: 16px; height: 16px; fill: currentColor; transition: transform var(--dur-2) var(--ease); }
.login-cta:hover { background: #fff; color: var(--rb-hero-a) !important; }
.login-cta:hover svg { transform: translateX(2px); }
.login-cta:focus-visible { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--rb-hero-a); }

.referral-banner { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--rb-pos-bg); border: 1px solid var(--rb-pos-line); color: var(--rb-pos-fg); font-size: 14px; }
.referral-banner[hidden] { display: none; }

.legal-foot { margin-top: 24px !important; font-size: 13px; color: var(--rb-muted); text-align: center; }
.legal-foot a { color: var(--rb-muted); display: inline-flex; min-height: 32px; align-items: center; }

/* ── Tablet ── */
@media (max-width: 1100px) {
  .register-panel { padding: 40px 36px; }
  .welcome-panel { padding: 48px 32px; }
}

/* ── Móvil: una columna, sin tarjeta; el panel de bienvenida pasa a ser una franja compacta arriba ── */
@media (max-width: 768px) {
  body.auth { display: block; padding: 0; background: var(--rb-surface); }
  .container { display: flex; flex-direction: column-reverse; min-height: 100dvh; border-radius: 0; box-shadow: none; max-width: none; }
  .register-panel { flex: 1 0 auto; justify-content: flex-start; padding: 28px max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .welcome-panel { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; text-align: left; gap: 14px; padding: max(20px, env(safe-area-inset-top)) 20px 20px; }
  .welcome-panel::before { width: 260px; height: 260px; right: -110px; top: -120px; }
  .welcome-panel::after { display: none; }
  .welcome-icon { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 14px; }
  .welcome-icon svg { width: 24px; height: 24px; }
  .welcome-panel h2 { font-size: 18px; }
  .welcome-panel p { margin-top: 2px !important; font-size: 14px; line-height: 1.45; }
  .welcome-panel .login-cta { display: none; }
  .auth .brand { display: none; }
  .title { font-size: 24px; }
  .auth-inner { max-width: 440px; }
}
@media (max-width: 380px) {
  .pw-rules { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .btn[aria-busy="true"] .spinner { animation: none; border-top-color: rgba(255, 255, 255, .45); border-right-color: #fff; }
}
@media (forced-colors: active) {
  .btn-primary, .check input:checked { forced-color-adjust: none; }
  .input, .alert { border: 1px solid CanvasText; }
}
