/* ==========================================================================
   RexiPuntos · Sistema de diseño compartido (mobile-first)
   Cargar en cada página: <link rel="stylesheet" href="rexi.css">
   ========================================================================== */

:root {
  /* Marca */
  --rx-primary: #2596be;
  --rx-primary-600: #1e7a9e;
  --rx-primary-700: #17627f;
  --rx-primary-50: #eef7fb;
  --rx-primary-100: #d6ecf5;
  --rx-primary-200: #a9d6e8;

  /* Neutros */
  --rx-bg: #f3f6f9;
  --rx-surface: #ffffff;
  --rx-surface-2: #f6f8fa;
  --rx-text: #0f172a;
  --rx-text-2: #475569;
  --rx-text-3: #94a3b8;
  --rx-border: #e5eaf0;

  /* Semánticos */
  --rx-success: #16a34a;
  --rx-success-bg: #ecfdf3;
  --rx-danger: #dc2626;
  --rx-danger-bg: #fef2f2;
  --rx-warning: #d97706;
  --rx-warning-bg: #fffbeb;
  --rx-wa: #25d366;
  --rx-wa-dark: #128c7e;

  /* Forma */
  --rx-radius-sm: 10px;
  --rx-radius: 16px;
  --rx-radius-lg: 22px;
  --rx-radius-xl: 28px;

  --rx-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 6px rgba(15, 23, 42, .04);
  --rx-shadow: 0 4px 16px rgba(15, 23, 42, .06);
  --rx-shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, .18);
  --rx-shadow-primary: 0 10px 24px -8px rgba(37, 150, 190, .55);

  --rx-font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Zonas seguras (iPhone con notch / barra de gestos) */
  --rx-safe-t: env(safe-area-inset-top, 0px);
  --rx-safe-b: env(safe-area-inset-bottom, 0px);

  --rx-page-max: 560px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--rx-font);
  background: var(--rx-bg);
  color: var(--rx-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--rx-primary); text-decoration: none; }
:focus-visible { outline: 3px solid var(--rx-primary-200); outline-offset: 2px; }

/* ---------- Layout ---------- */
.rx-page {
  width: 100%;
  max-width: var(--rx-page-max);
  margin: 0 auto;
  padding: 16px 16px calc(32px + var(--rx-safe-b));
}
.rx-stack > * + * { margin-top: 14px; }

/* App bar superior (páginas internas) */
.rx-appbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(243, 246, 249, .86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  padding-top: var(--rx-safe-t);
}
.rx-appbar__inner {
  max-width: var(--rx-page-max);
  margin: 0 auto;
  height: 60px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
}
.rx-appbar__title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rx-iconbtn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--rx-surface);
  color: var(--rx-text);
  box-shadow: var(--rx-shadow-sm);
  transition: transform .12s ease, background .2s;
}
.rx-iconbtn:active { transform: scale(.92); background: var(--rx-surface-2); }
.rx-iconbtn svg { width: 22px; height: 22px; }

/* ---------- Tarjetas ---------- */
.rx-card {
  background: var(--rx-surface);
  border-radius: var(--rx-radius-lg);
  box-shadow: var(--rx-shadow-sm);
  border: 1px solid rgba(15, 23, 42, .04);
  padding: 20px;
}
.rx-card--flat { box-shadow: none; }

/* ---------- Tipografía ---------- */
.rx-eyebrow {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--rx-text-3);
}
.rx-h1 { font-size: 26px; font-weight: 800; letter-spacing: -.6px; line-height: 1.2; }
.rx-h2 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.rx-muted { color: var(--rx-text-2); font-size: 14px; }
.rx-small { font-size: 12px; color: var(--rx-text-3); }

/* ---------- Botones ---------- */
.rx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  border-radius: var(--rx-radius);
  font-weight: 700; font-size: 15px;
  letter-spacing: .2px;
  transition: transform .12s ease, box-shadow .2s, background .2s, opacity .2s;
  user-select: none;
  -webkit-user-select: none;
}
.rx-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.rx-btn:active { transform: scale(.98); }
.rx-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.rx-btn--primary {
  background: linear-gradient(135deg, var(--rx-primary) 0%, var(--rx-primary-600) 100%);
  color: #fff;
  box-shadow: var(--rx-shadow-primary);
}
.rx-btn--secondary {
  background: var(--rx-primary-50);
  color: var(--rx-primary-600);
}
.rx-btn--ghost {
  background: var(--rx-surface);
  color: var(--rx-text-2);
  border: 1.5px solid var(--rx-border);
}
.rx-btn--success {
  background: linear-gradient(135deg, #22c55e, var(--rx-success));
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(22, 163, 74, .5);
}
.rx-btn--wa {
  background: var(--rx-wa);
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(37, 211, 102, .55);
}
.rx-btn--danger-soft { background: var(--rx-danger-bg); color: var(--rx-danger); }
.rx-btn--sm { min-height: 40px; padding: 0 14px; font-size: 13px; border-radius: 12px; width: auto; }
.rx-btn--link {
  width: auto; min-height: 44px; padding: 0 6px;
  background: none; color: var(--rx-text-2); font-weight: 600; font-size: 14px;
}
.rx-btn--link:hover { color: var(--rx-primary); }

/* ---------- Formularios ---------- */
.rx-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.rx-label { font-size: 13px; font-weight: 600; color: var(--rx-text-2); padding-left: 4px; }
.rx-hint { font-size: 12px; color: var(--rx-text-3); padding-left: 4px; }
.rx-input, .rx-select {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  background: var(--rx-surface-2);
  border: 1.5px solid transparent;
  border-radius: 14px;
  font-size: 16px; /* evita zoom automático en iOS */
  font-weight: 500;
  color: var(--rx-text);
  transition: border-color .2s, background .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.rx-input::placeholder { color: var(--rx-text-3); font-weight: 400; }
.rx-input:focus, .rx-select:focus {
  outline: none;
  background: #fff;
  border-color: var(--rx-primary);
  box-shadow: 0 0 0 4px rgba(37, 150, 190, .14);
}
.rx-input:disabled, .rx-select:disabled, .rx-input:read-only {
  background: #eceff3; color: var(--rx-text-2);
}
.rx-select {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.rx-select:invalid { color: var(--rx-text-3); }
.rx-input-wrap { position: relative; }
.rx-input-wrap .rx-input { padding-right: 52px; }
.rx-input-wrap__btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rx-text-3);
}
.rx-input-wrap__btn svg { width: 22px; height: 22px; }
.rx-input-wrap__btn.is-on { color: var(--rx-primary); }

.rx-check {
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 14px; color: var(--rx-text-2); cursor: pointer; line-height: 1.45;
}
.rx-check input {
  flex-shrink: 0;
  width: 22px; height: 22px; margin-top: 1px;
  accent-color: var(--rx-primary);
  cursor: pointer;
}
.rx-check a { font-weight: 700; }

/* PIN */
.rx-pin {
  width: 100%; max-width: 220px; margin: 0 auto;
  text-align: center; font-size: 30px; font-weight: 800;
  letter-spacing: 10px; text-indent: 10px;
  color: var(--rx-primary);
  background: #fff; border: 2px dashed var(--rx-primary-200);
}
.rx-pin:focus { border-style: solid; }

/* ---------- Mensajes de estado ---------- */
.rx-status {
  min-height: 22px;
  font-size: 14px; font-weight: 600; text-align: center;
  line-height: 1.45;
}
.rx-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 14px;
  font-size: 13px; font-weight: 500; line-height: 1.45;
}
.rx-alert svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.rx-alert--info { background: var(--rx-primary-50); color: var(--rx-primary-700); }
.rx-alert--success { background: var(--rx-success-bg); color: #166534; }
.rx-alert--danger { background: var(--rx-danger-bg); color: #991b1b; }
.rx-alert--warning { background: var(--rx-warning-bg); color: #92400e; }

/* ---------- Chips / badges ---------- */
.rx-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.rx-badge--success { background: var(--rx-success-bg); color: var(--rx-success); }
.rx-badge--warning { background: var(--rx-warning-bg); color: var(--rx-warning); }
.rx-badge--danger { background: var(--rx-danger-bg); color: var(--rx-danger); }
.rx-badge--neutral { background: var(--rx-surface-2); color: var(--rx-text-2); }

.rx-chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--rx-surface-2); color: var(--rx-text-2);
  font-size: 13px; font-weight: 600;
  border: 1.5px solid transparent;
  transition: .15s;
}
.rx-chip:active { transform: scale(.96); }
.rx-chip.is-active { background: var(--rx-primary-50); color: var(--rx-primary-600); border-color: var(--rx-primary-200); }

/* ---------- Skeleton ---------- */
.rx-skeleton {
  position: relative; overflow: hidden;
  background: #e7ecf1; border-radius: 8px;
  color: transparent !important; user-select: none;
}
.rx-skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  transform: translateX(-100%);
  animation: rx-shimmer 1.4s infinite;
}
@keyframes rx-shimmer { to { transform: translateX(100%); } }

/* ---------- Bottom sheet / modal ---------- */
.rx-sheet {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(15, 23, 42, .5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.rx-sheet.is-open { opacity: 1; visibility: visible; }
.rx-sheet__panel {
  width: 100%; max-width: 520px;
  max-height: 88vh; max-height: 88dvh;
  overflow-y: auto;
  background: var(--rx-surface);
  border-radius: var(--rx-radius-xl) var(--rx-radius-xl) 0 0;
  padding: 12px 22px calc(24px + var(--rx-safe-b));
  transform: translateY(40px);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,.15);
}
.rx-sheet.is-open .rx-sheet__panel { transform: translateY(0); }
.rx-sheet__handle {
  width: 44px; height: 5px; border-radius: 999px;
  background: var(--rx-border); margin: 0 auto 16px;
}
.rx-sheet__close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--rx-surface-2); color: var(--rx-text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.rx-sheet__close svg { width: 18px; height: 18px; }
@media (min-width: 600px) {
  .rx-sheet { align-items: center; padding: 20px; }
  .rx-sheet__panel { border-radius: var(--rx-radius-xl); padding-bottom: 24px; }
  .rx-sheet__handle { display: none; }
}

/* Modal centrado (alertas / confirmaciones) */
.rx-dialog {
  position: fixed; inset: 0; z-index: 1100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(15, 23, 42, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.rx-dialog.is-open { opacity: 1; visibility: visible; }
.rx-dialog__box {
  width: 100%; max-width: 360px;
  background: var(--rx-surface);
  border-radius: var(--rx-radius-lg);
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: var(--rx-shadow-lg);
  transform: scale(.94) translateY(10px);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
.rx-dialog.is-open .rx-dialog__box { transform: none; }
.rx-dialog__icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.rx-dialog__icon svg { width: 32px; height: 32px; }
.rx-dialog__icon--info { background: var(--rx-primary-50); color: var(--rx-primary); }
.rx-dialog__icon--success { background: var(--rx-success-bg); color: var(--rx-success); }
.rx-dialog__icon--danger { background: var(--rx-danger-bg); color: var(--rx-danger); }
.rx-dialog__title { font-size: 18px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 6px; }
.rx-dialog__text { font-size: 14px; color: var(--rx-text-2); line-height: 1.55; }
.rx-dialog__actions { display: flex; gap: 10px; margin-top: 20px; }
.rx-dialog__actions .rx-btn { min-height: 48px; font-size: 14px; }

/* ---------- Barra inferior fija (CTA) ---------- */
.rx-bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--rx-border);
  padding: 12px 16px calc(12px + var(--rx-safe-b));
}
.rx-bottombar__inner { max-width: var(--rx-page-max); margin: 0 auto; }

/* ---------- Auth (login / registro / recuperar) ---------- */
.rx-auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(24px + var(--rx-safe-t)) 20px calc(24px + var(--rx-safe-b));
}
.rx-auth__card {
  width: 100%; max-width: 440px;
  margin: auto 0;
  animation: rx-rise .5s cubic-bezier(.2, .9, .3, 1);
}
@media (min-width: 600px) {
  .rx-auth { background: radial-gradient(1200px 600px at 50% -10%, var(--rx-primary-100), var(--rx-bg) 60%); }
  .rx-auth__card {
    background: var(--rx-surface);
    border-radius: var(--rx-radius-xl);
    padding: 36px 32px;
    box-shadow: var(--rx-shadow-lg);
  }
}
.rx-auth__logo { width: min(240px, 68%); margin: 0 auto 24px; }
.rx-auth__footer {
  margin-top: 28px; padding-top: 18px;
  border-top: 1px solid var(--rx-border);
  text-align: center; font-size: 11px; color: var(--rx-text-3); line-height: 1.6;
}
.rx-auth__footer strong { color: var(--rx-text-2); }
.rx-auth__links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.rx-auth__links a { color: var(--rx-text-3); font-weight: 500; }
.rx-auth__links a:hover { color: var(--rx-primary); }

/* ---------- Animaciones ---------- */
@keyframes rx-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes rx-fade { from { opacity: 0; } to { opacity: 1; } }
.rx-rise { animation: rx-rise .45s cubic-bezier(.2, .9, .3, 1) both; }
.rx-shake { animation: rx-shake .4s; }
@keyframes rx-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Utilidades ---------- */
.rx-text-center { text-align: center; }
.rx-mt-1 { margin-top: 8px; } .rx-mt-2 { margin-top: 14px; } .rx-mt-3 { margin-top: 22px; }
.rx-hidden { display: none !important; }
.rx-row { display: flex; align-items: center; gap: 10px; }
.rx-grow { flex: 1; min-width: 0; }
