/* assets/css/auth.css - Pantallas publicas de acceso: recuperar / espera */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --auth-bg-deep: #0b1120;
    --auth-bg-mid: #131c30;
    --auth-card: rgba(20, 28, 46, 0.72);
    --auth-border: rgba(255, 255, 255, 0.09);
    --auth-text: #f1f5f9;
    --auth-muted: #93a1b8;
    --auth-cyan: #22d3ee;
    --auth-cyan-deep: #0891b2;
    --auth-blue: #3b82f6;
    --auth-amber: #fbbf24;
    --auth-green: #34d399;
    --auth-red: #f87171;
    --auth-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --auth-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body.auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: var(--auth-body);
    color: var(--auth-text);
    background: var(--auth-bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 18px;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- fondo en capas: gradiente base + trama + glow direccional + grano ---- */
.auth-bg { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
.auth-bg--base {
    background: radial-gradient(120% 90% at 50% -10%, var(--auth-bg-mid) 0%, var(--auth-bg-deep) 62%);
}
.auth-bg--grid {
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(120% 80% at 50% 18%, #000 30%, transparent 78%);
    mask-image: radial-gradient(120% 80% at 50% 18%, #000 30%, transparent 78%);
}
.auth-bg--glow {
    background:
        radial-gradient(40% 50% at 12% 8%, rgba(34, 211, 238, 0.16) 0%, transparent 60%),
        radial-gradient(38% 46% at 92% 96%, rgba(59, 130, 246, 0.14) 0%, transparent 60%);
}
.auth-bg--grain {
    opacity: 0.5;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ---- shell + card con borde-gradiente ---- */
.auth-shell { width: 100%; max-width: 460px; position: relative; }
.auth-card {
    position: relative;
    border-radius: 26px;
    padding: 40px 38px 34px;
    background: var(--auth-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: authRise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    overflow: hidden;
}
.auth-card::before {
    content: '';
    position: absolute; inset: 0;
    border-radius: 26px;
    padding: 1px;
    background: linear-gradient(150deg, rgba(34, 211, 238, 0.55), rgba(255, 255, 255, 0.04) 38%, rgba(59, 130, 246, 0.35));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}
.auth-card::after {
    content: '';
    position: absolute; top: -40%; left: 50%; transform: translateX(-50%);
    width: 70%; height: 60%;
    background: radial-gradient(closest-side, rgba(34, 211, 238, 0.12), transparent 70%);
    pointer-events: none;
}
@keyframes authRise { from { opacity: 0; transform: translateY(26px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---- marca ---- */
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-brand-mark {
    width: 42px; height: 42px; border-radius: 13px;
    display: grid; place-items: center;
    background: linear-gradient(150deg, var(--auth-cyan), var(--auth-cyan-deep));
    color: #04222b; font-size: 1.15rem;
    box-shadow: 0 8px 22px -6px rgba(34, 211, 238, 0.6);
}
.auth-brand-name { font-family: var(--auth-display); font-weight: 600; letter-spacing: 0.02em; font-size: 0.95rem; }
.auth-brand-name small { display: block; font-family: var(--auth-body); font-weight: 500; color: var(--auth-muted); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; }

.auth-eyebrow {
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--auth-cyan); margin: 0 0 8px;
}
.auth-title {
    font-family: var(--auth-display);
    font-size: clamp(1.7rem, 5vw, 2.35rem);
    font-weight: 700; line-height: 1.04; letter-spacing: -0.02em;
    margin: 0 0 10px;
}
.auth-lead { color: var(--auth-muted); font-size: 0.95rem; line-height: 1.55; margin: 0 0 26px; }

/* ---- campos ---- */
.auth-field { position: relative; margin-bottom: 18px; text-align: left; }
.auth-field label {
    display: block; margin-bottom: 8px;
    font-size: 0.78rem; font-weight: 600; color: var(--auth-muted); letter-spacing: 0.02em;
}
.auth-input-wrap { position: relative; }
.auth-input-wrap > i.lead-ico {
    position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
    color: var(--auth-muted); font-size: 0.95rem; transition: color 0.25s ease;
    pointer-events: none;
}
.auth-input {
    width: 100%; padding: 14px 16px 14px 44px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid var(--auth-border); border-radius: 14px;
    color: var(--auth-text); font-size: 1rem; font-family: var(--auth-body);
    outline: none; transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.auth-input::placeholder { color: rgba(148, 163, 184, 0.45); }
.auth-input:focus { border-color: var(--auth-cyan); background: rgba(0, 0, 0, 0.42); box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.13); }
.auth-field:focus-within .lead-ico { color: var(--auth-cyan); }
.auth-input.code { text-align: center; letter-spacing: 6px; text-transform: uppercase; font-weight: 700; font-family: var(--auth-display); padding-left: 16px; }

/* ---- boton principal con shimmer ---- */
.auth-btn {
    position: relative; width: 100%; padding: 15px;
    border: none; border-radius: 999px; cursor: pointer;
    background: linear-gradient(145deg, var(--auth-cyan), var(--auth-cyan-deep));
    color: #04222b; font-family: var(--auth-body); font-size: 1rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    overflow: hidden; transition: transform 0.2s ease, box-shadow 0.25s ease;
    box-shadow: 0 12px 28px -10px rgba(34, 211, 238, 0.6);
}
.auth-btn::after {
    content: ''; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: skewX(-18deg); transition: left 0.6s ease;
}
.auth-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(34, 211, 238, 0.7); }
.auth-btn:hover::after { left: 130%; }
.auth-btn:active { transform: translateY(0); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none; }
.auth-btn:disabled::after { display: none; }
.auth-btn.is-success { background: linear-gradient(145deg, var(--auth-green), #059669); color: #04231a; box-shadow: 0 12px 28px -10px rgba(16, 185, 129, 0.6); }

/* ---- links ---- */
.auth-links { display: flex; justify-content: center; gap: 18px; margin-top: 22px; flex-wrap: wrap; }
.auth-link { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-size: 0.86rem; color: var(--auth-muted); transition: color 0.2s; }
.auth-link:hover { color: var(--auth-text); }
.auth-link.accent { color: var(--auth-cyan); }
.auth-link.accent:hover { color: #67e8f9; }
.auth-sep { color: rgba(148, 163, 184, 0.4); }
.auth-foot { text-align: center; margin-top: 20px; font-size: 0.72rem; color: rgba(148, 163, 184, 0.55); letter-spacing: 0.02em; }

/* ============================================================
   STEPPER del flujo (reacciona a html[data-pr-step])
   ============================================================ */
.pr-stepper { display: flex; align-items: flex-start; justify-content: space-between; position: relative; margin: 4px 0 26px; padding: 0 4px; }
.pr-stepper-track { position: absolute; top: 15px; left: 22px; right: 22px; height: 3px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
.pr-stepper-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, var(--auth-cyan), var(--auth-blue)); border-radius: 3px; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pr-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }
.pr-step-dot {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--auth-bg-mid); border: 2px solid rgba(255, 255, 255, 0.14);
    color: var(--auth-muted); font-family: var(--auth-display); font-weight: 700; font-size: 0.82rem;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pr-step-label { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--auth-muted); text-align: center; transition: color 0.3s; max-width: 78px; line-height: 1.3; }

html[data-pr-step="pendiente"]         .pr-stepper-fill { width: 2%; }
html[data-pr-step="esperando_codigo"]  .pr-stepper-fill { width: 34%; }
html[data-pr-step="codigo_validado"]   .pr-stepper-fill { width: 67%; }
html[data-pr-step="password_generada"] .pr-stepper-fill { width: 100%; }

html[data-pr-step="pendiente"]         .pr-step[data-node="1"] .pr-step-dot,
html[data-pr-step="esperando_codigo"]  .pr-step[data-node="2"] .pr-step-dot,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="3"] .pr-step-dot,
html[data-pr-step="password_generada"] .pr-step[data-node="4"] .pr-step-dot {
    border-color: var(--auth-cyan); color: #04222b; background: linear-gradient(150deg, var(--auth-cyan), var(--auth-cyan-deep));
    box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.14);
    animation: prPulse 1.8s ease-in-out infinite;
}
html[data-pr-step="pendiente"]         .pr-step[data-node="1"] .pr-step-label,
html[data-pr-step="esperando_codigo"]  .pr-step[data-node="2"] .pr-step-label,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="3"] .pr-step-label,
html[data-pr-step="password_generada"] .pr-step[data-node="4"] .pr-step-label { color: var(--auth-text); }
@keyframes prPulse { 0%,100% { box-shadow: 0 0 0 5px rgba(34,211,238,0.14); } 50% { box-shadow: 0 0 0 9px rgba(34,211,238,0.05); } }

html[data-pr-step="esperando_codigo"]  .pr-step[data-node="1"] .pr-step-dot,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="1"] .pr-step-dot,
html[data-pr-step="password_generada"] .pr-step[data-node="1"] .pr-step-dot,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="2"] .pr-step-dot,
html[data-pr-step="password_generada"] .pr-step[data-node="2"] .pr-step-dot,
html[data-pr-step="password_generada"] .pr-step[data-node="3"] .pr-step-dot {
    border-color: var(--auth-green); background: rgba(16, 185, 129, 0.16); color: var(--auth-green);
    animation: none;
}
html[data-pr-step="esperando_codigo"]  .pr-step[data-node="1"] .pr-step-dot .num,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="1"] .pr-step-dot .num,
html[data-pr-step="password_generada"] .pr-step[data-node="1"] .pr-step-dot .num,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="2"] .pr-step-dot .num,
html[data-pr-step="password_generada"] .pr-step[data-node="2"] .pr-step-dot .num,
html[data-pr-step="password_generada"] .pr-step[data-node="3"] .pr-step-dot .num { display: none; }
.pr-step-dot .chk { display: none; }
html[data-pr-step="esperando_codigo"]  .pr-step[data-node="1"] .pr-step-dot .chk,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="1"] .pr-step-dot .chk,
html[data-pr-step="password_generada"] .pr-step[data-node="1"] .pr-step-dot .chk,
html[data-pr-step="codigo_validado"]   .pr-step[data-node="2"] .pr-step-dot .chk,
html[data-pr-step="password_generada"] .pr-step[data-node="2"] .pr-step-dot .chk,
html[data-pr-step="password_generada"] .pr-step[data-node="3"] .pr-step-dot .chk { display: inline; }

/* ---- panel de estado ---- */
.auth-status {
    background: rgba(0, 0, 0, 0.26); border: 1px solid var(--auth-border);
    border-radius: 18px; padding: 24px 20px; text-align: center; min-height: 96px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
#estado-icono { font-size: 2.3rem; color: var(--auth-cyan); line-height: 1; animation: prFloat 2.4s ease-in-out infinite; }
@keyframes prFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
#estado-mensaje { font-family: var(--auth-display); font-weight: 600; font-size: 1.02rem; line-height: 1.4; }
#estado-sub { font-size: 0.82rem; color: var(--auth-muted); line-height: 1.45; }

.auth-block { margin-top: 14px; animation: authReveal 0.45s cubic-bezier(0.2,0.8,0.2,1) both; }
@keyframes authReveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.auth-hint { font-size: 0.74rem; color: var(--auth-muted); margin-top: 8px; display: flex; align-items: center; gap: 7px; }
.auth-hint i { color: var(--auth-cyan); }

.auth-waitbox { background: rgba(251, 191, 36, 0.07); border: 1px solid rgba(251, 191, 36, 0.22); border-radius: 14px; padding: 16px; display: flex; gap: 12px; align-items: center; text-align: left; }
.auth-waitbox i { color: var(--auth-amber); font-size: 1.4rem; flex: none; }
.auth-waitbox p { margin: 0; font-size: 0.85rem; color: var(--auth-muted); line-height: 1.45; }
.auth-waitbox strong { color: var(--auth-text); }

.pr-keybox { background: rgba(0, 0, 0, 0.34); border: 1px solid rgba(251, 191, 36, 0.3); border-radius: 18px; padding: 24px 20px; text-align: center; }
.pr-key { font-family: var(--auth-display); font-size: clamp(1.4rem, 6vw, 1.9rem); font-weight: 700; letter-spacing: 3px; color: var(--auth-amber); word-break: break-all; user-select: all; margin: 12px 0 16px; }

/* ---- toast publico ---- */
#pr-toast-stack { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.pr-toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 13px 16px; border-radius: 14px;
    background: rgba(15, 23, 42, 0.92); border: 1px solid var(--auth-border);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
    font-size: 0.86rem; line-height: 1.4; color: var(--auth-text);
    animation: prToastIn 0.35s cubic-bezier(0.2,0.8,0.2,1) both;
}
.pr-toast.leaving { animation: prToastOut 0.3s ease forwards; }
.pr-toast i { margin-top: 1px; flex: none; }
.pr-toast.t-success { border-color: rgba(52, 211, 153, 0.4); }
.pr-toast.t-success i { color: var(--auth-green); }
.pr-toast.t-error { border-color: rgba(248, 113, 113, 0.4); }
.pr-toast.t-error i { color: var(--auth-red); }
.pr-toast.t-info i { color: var(--auth-cyan); }
@keyframes prToastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes prToastOut { to { opacity: 0; transform: translateX(24px); } }

@media (max-width: 480px) {
    .auth-card { padding: 32px 22px 28px; border-radius: 22px; }
    .pr-step-label { font-size: 0.54rem; }
    #pr-toast-stack { left: 14px; right: 14px; max-width: none; }
}