/* ============================================================
   Vecinda — Auth shell (login, registro, recuperar contraseña)
   Comparte tokens y tipografía con index.html para continuidad
   de marca entre el flujo pre-login y el dashboard.
   ============================================================ */

:root {
  --bg: #f7f5fa;
  --surface: #ffffff;
  --surface-border: #e4deec;
  --ink: #211c2b;
  --ink-muted: #6b6478;
  --accent: #6c4f9e;
  --accent-soft: #ede7f6;
  --accent-ink: #ffffff;
  --success: #1f8a5f;
  --success-soft: #e3f3ea;
  --warning: #b8790a;
  --warning-soft: #fbf0dd;
  --critical: #c4433a;
  --critical-soft: #fbe7e4;
  --divider: #e4deec;
  --shadow: 0 1px 2px rgba(33, 28, 43, 0.04), 0 8px 24px -12px rgba(33, 28, 43, 0.12);

  /* Panel de marca — se mantiene constante entre temas, igual que el sidebar del dashboard */
  --sb-bg: #1b1526;
  --sb-fg: #d9d2e6;
  --sb-fg-muted: #8f84a3;
  --sb-active-bg: #2e2342;
  --sb-accent: #b79fe0;
  --sb-border: #322a4a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15121c;
    --surface: #1e1929;
    --surface-border: #322a40;
    --ink: #ede9f2;
    --ink-muted: #a79fb5;
    --accent: #b79fe0;
    --accent-soft: #2e2640;
    --accent-ink: #1b1526;
    --success: #4fbe8b;
    --success-soft: #16362a;
    --warning: #e0a63c;
    --warning-soft: #3a2c13;
    --critical: #e2685d;
    --critical-soft: #3c1f1c;
    --divider: #322a40;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #15121c;
  --surface: #1e1929;
  --surface-border: #322a40;
  --ink: #ede9f2;
  --ink-muted: #a79fb5;
  --accent: #b79fe0;
  --accent-soft: #2e2640;
  --accent-ink: #1b1526;
  --success: #4fbe8b;
  --success-soft: #16362a;
  --warning: #e0a63c;
  --warning-soft: #3a2c13;
  --critical: #e2685d;
  --critical-soft: #3c1f1c;
  --divider: #322a40;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; }
.num { font-family: "IBM Plex Mono", ui-monospace, "SF Mono", monospace; font-variant-numeric: tabular-nums; }

/* ---------- Shell: brand panel + form panel ---------- */
.auth-shell {
  display: grid;
  grid-template-columns: 5fr 7fr;
  min-height: 100vh;
}

.auth-brand {
  background: var(--sb-bg);
  color: var(--sb-fg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.auth-brand .brand-mark {
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  color: #fff;
  letter-spacing: -0.01em;
}
.auth-brand .brand-dot { color: var(--sb-accent); }
.auth-brand .pitch {
  max-width: 340px;
  font-size: 20px;
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-weight: 500;
  line-height: 1.4;
  text-wrap: balance;
  color: #fff;
}
.auth-brand .pitch small {
  display: block;
  margin-top: 14px;
  font-family: "Manrope", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--sb-fg-muted);
}
.skyline { position: absolute; left: 0; right: 0; bottom: 0; opacity: 0.5; }

/* ---------- Form panel ---------- */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card .mobile-mark {
  display: none;
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 28px;
}
.auth-card .mobile-mark .brand-dot { color: var(--accent); }

.auth-card .eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 8px;
}
.auth-card h1 {
  font-size: 24px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.auth-card .lede {
  color: var(--ink-muted);
  font-size: 13.5px;
  margin: 0 0 26px;
  line-height: 1.5;
}
.auth-card .lede strong { color: var(--ink); font-weight: 700; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.field .hint { font-size: 11.5px; color: var(--ink-muted); }
.input, select.input {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  appearance: none;
}
.input::placeholder { color: var(--ink-muted); opacity: 0.85; }
.input:focus, select.input:focus, .otp-group input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6478' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.password-field { position: relative; }
.password-field .input { padding-right: 42px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ink-muted); cursor: pointer;
  padding: 6px; border-radius: 6px; display: flex;
}
.password-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.password-toggle .icon-eye-off { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye-off { display: block; }

.checkbox-field {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 12.5px; color: var(--ink-muted);
  margin-bottom: 20px; line-height: 1.45;
}
.checkbox-field input { margin-top: 2px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.checkbox-field a { color: var(--accent); font-weight: 600; }

/* ---------- Alertas y errores de validación (respuestas reales del API) ---------- */
.form-alert {
  background: var(--critical-soft); color: var(--critical);
  border-radius: 9px; padding: 10px 13px; font-size: 12.5px; font-weight: 600;
  margin-bottom: 16px; line-height: 1.4;
}
.form-alert.info { background: var(--accent-soft); color: var(--accent); }
.field-error { display: block; font-size: 11.5px; color: var(--critical); margin-top: 5px; }
.input.has-error, select.input.has-error { border-color: var(--critical); }

.phone-row { display: flex; gap: 8px; }
.phone-row .code { max-width: 92px; flex: none; }

/* ---------- Estado de carga en botones ---------- */
.btn-primary .spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 7px; vertical-align: -2px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); border-top-color: currentColor;
  animation: auth-spin 0.7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-primary .spinner { animation-duration: 1.4s; } }

.strength { display: flex; gap: 4px; margin-top: 8px; }
.strength i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-border); font-style: normal; }
.strength .label { font-size: 11px; color: var(--ink-muted); margin-top: 4px; display: block; }
.strength.weak i:nth-child(1) { background: var(--critical); }
.strength.medium i:nth-child(-n+2) { background: var(--warning); }
.strength.strong i { background: var(--success); }

/* ---------- Buttons & links ---------- */
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 9px; padding: 12px; font-weight: 700; font-size: 14px;
  cursor: pointer; width: 100%; margin-top: 4px;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.75; cursor: not-allowed; filter: none; }
.btn-primary:focus-visible, .link-btn:focus-visible, .input:focus-visible, .role-card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.link-btn {
  background: none; border: none; color: var(--accent); font-weight: 700;
  cursor: pointer; padding: 0; font-size: 13px; font-family: inherit;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-muted); font-size: 13px; font-weight: 600;
  text-decoration: none; margin-bottom: 22px; background: none; border: none; cursor: pointer; padding: 0;
}
.back-link:hover { color: var(--ink); }

.foot-note {
  text-align: center; font-size: 13px; color: var(--ink-muted); margin-top: 26px;
}
.foot-note .link-btn, .foot-note a { font-weight: 700; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Role choice cards (registro) ---------- */
.role-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.role-card {
  border: 1.5px solid var(--surface-border); background: var(--surface);
  border-radius: 12px; padding: 14px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; font-family: inherit;
}
.role-card .ic {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.role-card .title { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.role-card .desc { font-size: 11.5px; color: var(--ink-muted); }
.role-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.role-card[aria-pressed="true"] .ic { background: var(--accent); color: var(--accent-ink); }
.role-card:disabled { opacity: 0.55; cursor: not-allowed; }
.role-card:disabled:hover { border-color: var(--surface-border); }
.role-card .soon-badge {
  align-self: flex-start; font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-muted); background: var(--surface-border);
  padding: 2px 7px; border-radius: 999px;
}

/* ---------- OTP ---------- */
.otp-group { display: flex; gap: 8px; justify-content: space-between; margin: 6px 0 18px; }
.otp-group input {
  width: 100%; max-width: 48px; height: 56px; text-align: center; font-size: 22px;
  font-family: "IBM Plex Mono", monospace; border: 1px solid var(--surface-border);
  border-radius: 10px; background: var(--surface); color: var(--ink);
}
.resend-row { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 22px; }

/* ---------- Success / confirmation states ---------- */
.state-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center; margin: 0 0 20px;
}
.state-icon.info { background: var(--accent-soft); color: var(--accent); }
.center { text-align: center; }
.center .state-icon { margin-left: auto; margin-right: auto; }

[hidden] { display: none !important; }

/* ---------- Chips de estado (reclamaciones, cuotas) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.pagado, .chip.approved, .chip.active { background: var(--success-soft); color: var(--success); }
.chip.pendiente, .chip.pending, .chip.verification_pending { background: var(--warning-soft); color: var(--warning); }
.chip.vencido, .chip.rejected, .chip.corrections_requested { background: var(--critical-soft); color: var(--critical); }
.chip.cancelled { background: var(--surface-border); color: var(--ink-muted); }
.chip.review, .chip.return_pending { background: var(--warning-soft); color: var(--warning); }
.chip.awaiting_pickup { background: var(--accent-soft); color: var(--accent); }
.chip.delivered { background: var(--success-soft); color: var(--success); }
.chip.lost { background: var(--critical-soft); color: var(--critical); }
.chip.returned { background: var(--surface-border); color: var(--ink-muted); }
.chip.draft { background: var(--surface-border); color: var(--ink-muted); }
.chip.scheduled { background: var(--accent-soft); color: var(--accent); }
.chip.published { background: var(--success-soft); color: var(--success); }
.chip.deleted { background: var(--surface-border); color: var(--ink-muted); }
.chip.priority-high { background: var(--critical-soft); color: var(--critical); }
.chip.priority-medium { background: var(--warning-soft); color: var(--warning); }
.chip.priority-low { background: var(--surface-border); color: var(--ink-muted); }
.chip.emergency-open { background: var(--critical-soft); color: var(--critical); }
.chip.emergency-resolved { background: var(--success-soft); color: var(--success); }

/* ---------- Selector de unidades (registro de residente, invitación masiva) ---------- */
.unit-picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.unit-option {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--surface-border); background: var(--surface);
  border-radius: 10px; padding: 11px 13px; cursor: pointer;
}
.unit-option input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.unit-option .unit-name { font-weight: 700; font-size: 13.5px; }
.unit-option .unit-meta { font-size: 11.5px; color: var(--ink-muted); }
.unit-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Tarjetas informativas (condominio detectado por el token, etc.) ---------- */
.info-card {
  background: var(--accent-soft); border-radius: 11px; padding: 12px 14px;
  font-size: 12.5px; color: var(--ink); margin-bottom: 18px; line-height: 1.5;
}
.info-card strong { display: block; font-size: 14px; margin-bottom: 2px; }

/* ---------- Tarjetas de reclamación (portal del residente) ---------- */
.claim-card {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.claim-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.claim-card .unit-name { font-weight: 700; font-size: 14.5px; }
.claim-card .condo-name { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.claim-card .status-note {
  font-size: 12.5px; color: var(--ink-muted); margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--divider, var(--surface-border));
}
.claim-card .status-note strong { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card .mobile-mark { display: block; }
  .auth-panel { padding: 32px 20px; }
}
@media (max-width: 380px) {
  .otp-group input { height: 50px; font-size: 19px; }
  .role-choice { grid-template-columns: 1fr; }
}
