/* ==============================================================
   Territorio Común — Autenticación (login / registro / recuperar)
   Coherente con el sistema del área privada:
   - Paleta ocre/crema en oklch
   - Cormorant Garamond (serif) + Karla (sans)
   - Radios pequeños, sombras cálidas, mucho aire
============================================================== */

:root {
  --background: oklch(0.965 0.018 75);
  --foreground: oklch(0.24 0.03 45);
  --card: oklch(0.985 0.012 80);
  --primary: oklch(0.55 0.13 55);
  --primary-hover: oklch(0.48 0.14 55);
  --primary-foreground: oklch(0.98 0.01 80);
  --muted: oklch(0.92 0.025 72);
  --muted-foreground: oklch(0.45 0.04 50);
  --accent: oklch(0.72 0.14 65);
  --border: oklch(0.85 0.03 70);
  --danger: oklch(0.55 0.18 25);
  --success: oklch(0.55 0.12 145);

  --font-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
  --font-sans: "Karla", ui-sans-serif, system-ui, sans-serif;

  --shadow-warm: 0 40px 100px -40px oklch(0.35 0.1 50 / 0.35);
  --shadow-soft: 0 1px 0 oklch(0.4 0.1 50 / 0.04), 0 12px 32px -16px oklch(0.4 0.1 50 / 0.15);

  --ring: color-mix(in oklch, var(--primary) 45%, transparent);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ================== LAYOUT ================== */
.auth {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .auth {
    grid-template-columns: 1.05fr 1fr;
  }
}

/* Panel izquierdo — imagen / manifiesto */
.auth-aside {
  display: none;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 20% 10%, oklch(0.72 0.14 65 / 0.35), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, oklch(0.55 0.13 55 / 0.45), transparent 55%),
    linear-gradient(180deg, oklch(0.32 0.06 55), oklch(0.22 0.04 50));
  color: oklch(0.98 0.01 80);
  padding: 3.5rem;
}

@media (min-width: 960px) {
  .auth-aside { display: flex; flex-direction: column; justify-content: space-between; }
}

.auth-aside::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(oklch(1 0 0 / 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .35;
  pointer-events: none;
}

.aside-brand {
  display: inline-flex; align-items: center; gap: .7rem;
  position: relative; z-index: 1;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: .01em;
}
.aside-brand span { font-weight: 500; }

.aside-brand .mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 2px;
  background: oklch(1 0 0 / 0.08);
  border: 1px solid oklch(1 0 0 / 0.14);
}

.aside-quote {
  position: relative; z-index: 1;
  max-width: 32rem;
}
.aside-quote .eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: .72rem;
  color: oklch(0.85 0.04 80);
  margin-bottom: 1.25rem;
}
.aside-quote h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
}
.aside-quote h2 em {
  font-style: italic;
  color: oklch(0.85 0.09 75);
}
.aside-quote p {
  margin-top: 1.25rem;
  color: oklch(0.9 0.02 80);
  max-width: 26rem;
}

.aside-foot {
  position: relative; z-index: 1;
  font-size: .82rem;
  color: oklch(0.85 0.02 80);
  display: flex; gap: 1.25rem;
}
.aside-foot a:hover { color: oklch(0.95 0.06 75); }

/* ================== PANEL FORMULARIO ================== */
.auth-main {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 25rem;
  display: flex; flex-direction: column;
  gap: 1.75rem;
}

/* Brand móvil (solo cuando aside oculto) */
.mobile-brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--foreground);
  margin-bottom: .25rem;
}
.mobile-brand .mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 2px;
  background: var(--muted);
  border: 1px solid var(--border);
  color: var(--primary);
}
@media (min-width: 960px) {
  .mobile-brand { display: none; }
}

.auth-head .eyebrow {
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: .72rem;
  color: var(--muted-foreground);
  margin-bottom: .75rem;
}
.auth-head h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.75rem, 2.4vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
}
.auth-head h1 em { font-style: italic; color: var(--primary); }
.auth-head p {
  color: var(--muted-foreground);
  margin-top: .5rem;
  font-size: .93rem;
}

/* ================== FORMULARIO ================== */
.form { display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: .4rem; }

.field label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted-foreground);
  font-weight: 500;
}

.input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.input-wrap svg { position: absolute; left: .85rem; color: var(--muted-foreground); }

.input {
  width: 100%;
  padding: .85rem 1rem;
  padding-left: 2.55rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input:hover { border-color: oklch(0.75 0.05 65); }
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.input.has-toggle { padding-right: 2.75rem; }

.pw-toggle {
  position: absolute; right: .55rem;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--muted-foreground);
  border-radius: 2px;
}
.pw-toggle:hover { color: var(--foreground); background: var(--muted); }

.field-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .88rem;
  color: var(--muted-foreground);
}
.field-row a { color: var(--primary); }
.field-row a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }

.check {
  display: inline-flex; align-items: center; gap: .55rem;
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--card);
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease;
}
.check input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.check input:checked::after {
  content: "";
  width: 8px; height: 8px;
  background:
    linear-gradient(45deg, transparent 42%, var(--primary-foreground) 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--primary-foreground) 42% 58%, transparent 58%);
  mask: none;
  transform: rotate(45deg) translate(-1px, -1px);
  background: var(--primary-foreground);
  clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 20%, 84% 8%, 40% 68%);
}

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .55rem;
  padding: .9rem 1.1rem;
  border-radius: 2px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary[disabled] { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--muted); }

.btn-block { width: 100%; }

/* Divisor "o" */
.divider {
  display: flex; align-items: center; gap: .9rem;
  color: var(--muted-foreground);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .2em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Alertas */
.alert {
  padding: .75rem .9rem;
  border-radius: 2px;
  font-size: .88rem;
  border: 1px solid var(--border);
  background: var(--muted);
  display: flex; gap: .6rem; align-items: flex-start;
}
.alert.error { border-color: color-mix(in oklch, var(--danger) 40%, var(--border));
  background: color-mix(in oklch, var(--danger) 10%, var(--card));
  color: var(--danger);
}
.alert.success { border-color: color-mix(in oklch, var(--success) 40%, var(--border));
  background: color-mix(in oklch, var(--success) 10%, var(--card));
  color: var(--success);
}
.alert[hidden] { display: none; }

/* Pie */
.auth-foot {
  text-align: center;
  color: var(--muted-foreground);
  font-size: .9rem;
}
.auth-foot a { color: var(--primary); }
.auth-foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid oklch(1 0 0 / 0.4);
  border-top-color: var(--primary-foreground);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Password strength */
.pw-strength {
  display: flex; gap: 4px; margin-top: .35rem;
}
.pw-strength span {
  flex: 1; height: 3px;
  background: var(--border);
  border-radius: 2px;
  transition: background .2s ease;
}
.pw-strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-strength[data-level="2"] span:nth-child(-n+2) { background: oklch(0.7 0.14 65); }
.pw-strength[data-level="3"] span:nth-child(-n+3) { background: var(--accent); }
.pw-strength[data-level="4"] span { background: var(--success); }

.hint {
  font-size: .8rem;
  color: var(--muted-foreground);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ================== AÑADIDO: estado de error por campo ================== */
/* No modifica ninguna regla existente. Se usa en el campo email del
   formulario de registro cuando el email ya está en uso o no es válido. */
.field.has-error .input {
  border-color: var(--danger);
}
.field.has-error label {
  color: var(--danger);
}
.field-error {
  font-size: .8rem;
  color: var(--danger);
  margin: 0;
}
