/* ==========================================================================
   Auth Portal — estilos (tema morado, personalizable)
   ========================================================================== */

:root {
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-3: #c4b5fd;
  --accent-glow: rgba(139, 92, 246, 0.45);
  --bg-1: #0a0612;
  --bg-2: #1a0f2e;
  --bg-3: #2d1b4e;
  --panel: rgba(20, 14, 35, 0.72);
  --panel-strong: rgba(28, 18, 48, 0.92);
  --ink: #f5f3ff;
  --muted: #a78bfa;
  --faint: #6d5a8a;
  --line: rgba(139, 92, 246, 0.18);
  --line-strong: rgba(139, 92, 246, 0.32);
  --danger: #f87171;
  --success: #34d399;
  --radius: 22px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: var(--bg-1);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- fondo ------------------------------------------------------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite alternate;
}
.orb-a {
  width: 50vw; height: 50vw; min-width: 400px; min-height: 400px;
  left: -10vw; top: -15vw;
  background: radial-gradient(circle, var(--accent), transparent 65%);
  animation-duration: 24s;
}
.orb-b {
  width: 40vw; height: 40vw; min-width: 320px; min-height: 320px;
  right: -8vw; top: 10vh;
  background: radial-gradient(circle, #ec4899, transparent 65%);
  animation-duration: 30s;
  animation-delay: -5s;
}
.orb-c {
  width: 35vw; height: 35vw; min-width: 280px; min-height: 280px;
  left: 30vw; bottom: -15vw;
  background: radial-gradient(circle, #3b82f6, transparent 65%);
  animation-duration: 35s;
  animation-delay: -10s;
}
.orb-d {
  width: 25vw; height: 25vw; min-width: 200px; min-height: 200px;
  right: 20vw; bottom: 20vh;
  background: radial-gradient(circle, #f59e0b, transparent 65%);
  animation-duration: 28s;
  animation-delay: -15s;
  opacity: 0.3;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4vw, -3vh) scale(1.1); }
  66% { transform: translate(-3vw, 4vh) scale(0.95); }
  100% { transform: translate(2vw, 2vh) scale(1.05); }
}

#particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- contenedor -------------------------------------------------- */
.container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---------- vistas ------------------------------------------------------ */
.view {
  display: none;
  width: 100%;
  max-width: 460px;
  animation: viewIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.view.active { display: block; }
.view.view-dashboard { max-width: 960px; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.view.exit {
  animation: viewOut 0.3s ease both;
}
@keyframes viewOut {
  to { opacity: 0; transform: translateY(-16px) scale(0.97); }
}

/* ---------- tarjeta ----------------------------------------------------- */
.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(165deg, rgba(28, 18, 48, 0.85), rgba(12, 8, 22, 0.9));
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.6),
              0 0 60px -10px var(--accent-glow),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 32px 30px;
  overflow: hidden;
}
.card-wide { max-width: 960px; }

.card-glow {
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 50%);
  opacity: 0.3;
  pointer-events: none;
  animation: glowPulse 6s ease-in-out infinite alternate;
}
@keyframes glowPulse {
  0% { opacity: 0.2; transform: scale(1); }
  100% { opacity: 0.4; transform: scale(1.1); }
}

/* ---------- marca ------------------------------------------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 30px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
  flex: none;
}
.brand-mark svg { width: 24px; height: 24px; }
.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, #fff 0%, var(--accent-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--faint);
}

/* ---------- formulario -------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--faint);
  pointer-events: none;
  transition: color 0.2s ease;
}
.input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.input-wrap input::placeholder { color: var(--faint); }
.input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-wrap:focus-within .input-icon { color: var(--accent-2); }

.toggle-pass {
  position: absolute;
  right: 10px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}
.toggle-pass:hover { color: var(--accent-2); background: rgba(139, 92, 246, 0.1); }
.toggle-pass svg { width: 18px; height: 18px; }

.error {
  font-size: 11.5px;
  color: var(--danger);
  min-height: 14px;
  line-height: 1.3;
}

/* ---------- fuerza de contraseña --------------------------------------- */
.strength {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 4px;
}
.strength span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
  background: var(--danger);
}
.strength.weak span { width: 25%; background: var(--danger); }
.strength.fair span { width: 50%; background: #f59e0b; }
.strength.good span { width: 75%; background: #3b82f6; }
.strength.strong span { width: 100%; background: var(--success); }

/* ---------- checkbox ---------------------------------------------------- */
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.checkbox input { display: none; }
.checkmark {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.3);
  display: grid; place-items: center;
  transition: all 0.2s ease;
  flex: none;
}
.checkbox input:checked + .checkmark {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 12px -2px var(--accent-glow);
}
.checkbox input:checked + .checkmark::after {
  content: "✓";
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.checkbox.terms { margin-top: 4px; }

/* ---------- botones ----------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease, opacity 0.2s ease;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 50%, var(--accent-2) 100%);
  box-shadow: 0 8px 28px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; border-radius: 9px; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- fila y divider --------------------------------------------- */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.switch-text {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}
.link-btn:hover { color: white; text-decoration: underline; }
.link-small {
  font-size: 12px;
  color: var(--accent-2);
  text-decoration: none;
  transition: color 0.2s ease;
}
.link-small:hover { color: white; }

/* ---------- dashboard --------------------------------------------------- */
.dash-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.avatar {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 32px;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  box-shadow: 0 0 30px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  flex: none;
}
.dash-info { flex: 1; min-width: 0; }
.dash-info h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.dash-info .subtitle { margin: 2px 0 0; font-size: 13px; color: var(--faint); }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 820px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.dash-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  padding: 20px;
}
.dash-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.dash-desc {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--faint);
}

/* ---------- color picker ----------------------------------------------- */
.color-picker, .avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 12px -2px var(--c);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 0 18px -2px var(--c);
}
.avatar-option {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: grid; place-items: center;
}
.avatar-option:hover { background: rgba(139, 92, 246, 0.15); border-color: var(--accent); }
.avatar-option.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 16px -4px var(--accent-glow);
}

/* ---------- quick links ------------------------------------------------- */
.quick-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
}
.quick-link:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--accent);
  transform: translateX(4px);
}
.ql-icon { font-size: 18px; }
.ql-icon svg { width: 18px; height: 18px; stroke: var(--accent-2); }
.quick-link svg { width: 14px; height: 14px; margin-left: auto; color: var(--faint); }

/* ---------- account info ----------------------------------------------- */
.account-info { display: flex; flex-direction: column; gap: 8px; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.info-value { color: var(--ink); font-family: var(--mono); font-size: 12px; }

/* ---------- toast ------------------------------------------------------- */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(20, 14, 35, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--accent-glow);
  font-size: 13px;
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { opacity: 1; transform: none; }
.toast[data-kind="ok"] { border-color: rgba(52, 211, 153, 0.5); }
.toast[data-kind="error"] { border-color: rgba(248, 113, 113, 0.5); }

/* ---------- responsive -------------------------------------------------- */
@media (max-width: 640px) {
  .container { padding: 16px; }
  .card { padding: 24px 20px; }
  .brand h1 { font-size: 20px; }
  .dash-header { flex-direction: column; text-align: center; }
  .dash-header .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
