/* ============================================ */
/* VARIABLES                                   */
/* ============================================ */
:root {
  --primary: #8d17fb;
  --primary-dim: rgba(141,23,251,0.15);
  --secondary: #70189b;
  --accent: #c084fc;

  --bg: #03010f;
  --bg2: #06011c;
  --card: rgba(14,11,30,0.92);
  --card-border: rgba(141,23,251,0.2);

  --text: #f0eaff;
  --text-2: rgba(200,185,230,0.8);
  --text-3: rgba(160,145,190,0.6);
  --border: rgba(60,45,90,0.7);

  --error:   #f43f5e;
  --success: #22c55e;

  --font: 'Inter', sans-serif;

  --glow: 0 0 20px rgba(141,23,251,0.4), 0 0 40px rgba(112,24,155,0.25);
  --glow-soft: 0 0 12px rgba(141,23,251,0.25);
}

/* ============================================ */
/* RESET BASE                                  */
/* ============================================ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html {
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-weight: 400;
  min-height: 100vh;
  min-height: 100svh;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top:    calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================ */
/* FONDO ANIMADO                               */
/* ============================================ */
.bg-orbs {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.35;
  animation: orbFloat 12s ease-in-out infinite;
  will-change: transform;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #8d17fb, transparent 70%);
  top: -100px; left: -100px; animation-delay: 0s;
}
.orb-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #3b1fa8, transparent 70%);
  bottom: -80px; right: -80px; animation-delay: -4s;
}
.orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, #c084fc, transparent 70%);
  top: 50%; left: 60%; animation-delay: -8s; opacity: 0.2;
}
@keyframes orbFloat {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(30px,-20px) scale(1.05); }
  66%      { transform: translate(-20px,30px) scale(0.95); }
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(141,23,251,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(141,23,251,0.04) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ============================================ */
/* AUTH CONTAINER + CARD                       */
/* ============================================ */
.auth-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 32px 28px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: cardIn 0.5s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes cardIn {
  from { opacity:0; transform: translateY(28px) scale(0.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* ============================================ */
/* LOGO                                        */
/* ============================================ */
.logo {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; margin-bottom: 24px; position: relative;
}
.logo-glow {
  position: absolute; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(141,23,251,0.3), transparent 70%);
  filter: blur(20px); top: -20px; pointer-events: none;
}
.logo img {
  width: 62px; height: 62px; object-fit: contain; border-radius: 14px;
  position: relative; z-index: 1;
  filter: drop-shadow(0 8px 20px rgba(141,23,251,0.5));
  animation: logoFloat 3.5s ease-in-out infinite;

  /* ✅ Fix: fuerza GPU layer — evita saltos en distintos PCs/browsers */
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
@keyframes logoFloat {
  0%,100% { transform: translateY(0) translateZ(0); }
  50%      { transform: translateY(-6px) translateZ(0); }
}
.logo-wordmark {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text);
  position: relative; z-index: 1;
  text-transform: uppercase;
}
.logo-wordmark span { color: var(--accent); }

/* ============================================ */
/* AUTH TABS                                   */
/* ============================================ */
.auth-tabs {
  display: flex; position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 11px; transition: color 0.25s;
  position: relative; z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.auth-tab.active { color: var(--text); }
.tab-indicator {
  position: absolute; top: 4px; left: 4px;
  width: calc(50% - 4px); height: calc(100% - 8px);
  background: linear-gradient(135deg, rgba(141,23,251,0.4), rgba(112,24,155,0.3));
  border: 1px solid rgba(141,23,251,0.4);
  border-radius: 11px;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

/* ============================================ */
/* FORMS                                       */
/* ============================================ */
.form { display: none; animation: formIn 0.3s ease; }
.form.active { display: block; }
@keyframes formIn {
  from { opacity:0; transform: translateX(8px); }
  to   { opacity:1; transform: translateX(0); }
}

.field-group { margin-bottom: 14px; }

.field-group > label {
  display: block;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* ============================================ */
/* INPUT WRAP                                  */
/* ============================================ */
.input-wrap {
  position: relative; display: flex; align-items: center;
}
.input-icon {
  position: absolute; left: 13px; width: 16px; height: 16px;
  fill: var(--text-3); pointer-events: none; flex-shrink: 0;
  transition: fill 0.2s;
}
.input-wrap:focus-within .input-icon { fill: var(--accent); }

input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-appearance: none;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}
input::placeholder { color: var(--text-3); font-weight: 400; }
input:focus {
  border-color: var(--primary);
  background: rgba(141,23,251,0.06);
  box-shadow: 0 0 0 3px rgba(141,23,251,0.15);
}
input:-webkit-autofill,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 40px #0d0820 inset !important;
  -webkit-text-fill-color: var(--text) !important;
}
input:invalid, input:valid, input:required { box-shadow: none !important; }
*:focus { outline: none; }

.toggle-pw {
  position: absolute; right: 12px;
  background: none; border: none; cursor: pointer;
  padding: 4px; opacity: 0.5; transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.toggle-pw svg { width: 18px; height: 18px; fill: var(--text-3); display: block; }
.toggle-pw:hover { opacity: 0.9; }

/* ============================================ */
/* PASSWORD STRENGTH                           */
/* ============================================ */
.pw-strength-wrap {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.pw-strength-bar {
  flex: 1; height: 3px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
#password-strength-bar {
  height: 100%; width: 0; border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}
.pw-strength-label {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  min-width: 44px;
  text-align: right;
}

/* ============================================ */
/* FORGOT                                      */
/* ============================================ */
.forgot {
  display: block; text-align: right;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent); text-decoration: none; margin-bottom: 18px;
  margin-top: -4px; transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.forgot:hover { opacity: 0.75; }

/* ============================================ */
/* PRIMARY BUTTON                              */
/* ============================================ */
.btn-primary {
  width: 100%; padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none; border-radius: 14px;
  color: white;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--glow-soft);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  margin-top: 8px;
}
.btn-primary svg { width: 18px; height: 18px; fill: white; flex-shrink: 0; }
.btn-primary:hover { box-shadow: var(--glow); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); box-shadow: none; }
.btn-primary:disabled { opacity: 0.45; pointer-events: none; }

/* ============================================ */
/* TERMS ROW                                   */
/* ============================================ */
.terms-row {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  margin: 14px 0; cursor: pointer;
}
.terms-row .link {
  color: var(--accent); text-decoration: none;
  font-weight: 500;
}
.terms-row input[type="checkbox"] { display: none; }

.toggle-switch {
  position: relative; display: inline-block;
  width: 46px; height: 24px; min-width: 46px; flex-shrink: 0;
}
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px;
  transition: background 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ============================================ */
/* DIVIDER                                     */
/* ============================================ */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  font-family: var(--font);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ============================================ */
/* SOCIAL BUTTONS                              */
/* ============================================ */
.social-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 46px;
}
.btn-social:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.15); }
.btn-social:active { transform: scale(0.97); }

/* ============================================ */
/* FOOTER                                      */
/* ============================================ */
footer {
  text-align: center; margin-top: 22px;
  padding-top: 18px; border-top: 1px solid var(--border);
}
footer p {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  margin-bottom: 8px;
}
.footer-links {
  display: flex; justify-content: center; gap: 4px; flex-wrap: wrap;
}
.footer-links a {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3); text-decoration: none;
  padding: 6px 8px; border-radius: 8px; transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.footer-links a:hover { color: var(--accent); }
.footer-links a:not(:last-child)::after {
  content: '·'; margin-left: 4px; color: var(--border);
}

/* ============================================ */
/* RECOVERY MODAL                              */
/* ============================================ */
.recovery-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); z-index: 50; cursor: pointer;
}
.recovery-overlay.active, .recovery-overlay.show { display: block; }

.recovery-container {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 24px; padding: 28px 24px;
  width: 90%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  z-index: 60; text-align: center;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: translate(-50%,-50%) scale(0.95); }
  to   { opacity:1; transform: translate(-50%,-50%) scale(1); }
}
.recovery-container.active, .recovery-container.show { display: block; }
.recovery-icon { font-size: 40px; margin-bottom: 12px; }
.recovery-container h3 {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}
.recovery-container p {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2); line-height: 1.55; margin-bottom: 4px;
}
.recovery-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.btn-ghost {
  width: 100%; padding: 12px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text-2);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:hover { background: rgba(255,255,255,0.09); }
.btn-ghost:active { transform: scale(0.98); }

/* ============================================ */
/* NOTIFICATION                                */
/* ============================================ */
.notification {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 12px 20px; border-radius: 12px;
  background: #1e1b4b; border: 1px solid rgba(141,23,251,0.4);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  display: none; z-index: 9999;
  max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.notification.show {
  display: block;
  animation: notifIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.notification.error  { background: rgba(244,63,94,0.15); border-color: var(--error); }
.notification.success{ background: rgba(34,197,94,0.12); border-color: var(--success); }
@keyframes notifIn {
  from { opacity:0; transform: translateX(-50%) translateY(16px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

/* ============================================ */
/* RESPONSIVE                                  */
/* ============================================ */
@media (max-width: 480px) {
  body { padding: 12px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .auth-card { padding: 24px 20px 20px; border-radius: 22px; }
  .logo img { width: 54px; }
  .logo-wordmark { font-size: 15px; }
}
@media (max-width: 350px) {
  .auth-card { padding: 20px 16px; }
  .social-btns { grid-template-columns: 1fr; }
}
@media screen and (max-width:768px) and (orientation:landscape) {
  body { align-items: flex-start; padding: 10px; }
  .auth-card { padding: 16px 20px; }
  .logo { flex-direction: row; margin-bottom: 16px; }
  .logo img { width: 40px; }
  .logo-glow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================ */
/* CAPACITOR NATIVE LOADING OVERLAY            */
/* Se muestra mientras Firebase verifica sesión */
/* en el arranque nativo. Se oculta desde JS.  */
/* ============================================ */
#cap-loading {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
}

/* ============================================ */
/* TERMS BOTTOM SHEET                          */
/* ============================================ */
.terms-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px); z-index: 70;
}
.terms-overlay.active { display: block; }

.terms-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 85vh;
  background: #0d0820;
  border: 1px solid var(--card-border);
  border-radius: 24px 24px 0 0;
  z-index: 71;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.terms-sheet.active { transform: translateY(0); }

.terms-sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 12px auto 0;
  flex-shrink: 0;
}

.terms-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.terms-sheet-header h3 {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.terms-close-btn {
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.terms-close-btn svg { width: 18px; height: 18px; fill: var(--text-2); }

.terms-sheet-body {
  flex: 1; overflow: hidden;
}
.terms-sheet-body iframe {
  width: 100%; height: 100%; border: none;
}
