/* ============================================================================
   auth.css — tema visual compartido de login / 2FA / recuperar-restablecer
   contraseña. Los 4 templates en app/Views/auth/*.php fijan las variables de
   color (--brand-rgb, --brand-light, --brand-dark, --bg-start, --bg-mid,
   --sec-rgb) en un <style> inline por página (derivadas de settings.brand_color)
   y enlazan este archivo para el resto. Self-hosted, sin CDN (CSP script-src
   'self' / regla dura del proyecto).
   ========================================================================== */

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

body.auth-body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-start) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Halos ambientales de fondo — puramente decorativos, derivan del color de marca */
body.auth-body::before,
body.auth-body::after {
    content: "";
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--brand-rgb), .30), transparent 70%);
    filter: blur(70px);
    z-index: 0;
    pointer-events: none;
    animation: authDrift 14s ease-in-out infinite;
}
body.auth-body::before { top: -140px; left: -120px; }
body.auth-body::after  { bottom: -160px; right: -120px; animation-delay: -7s; }

@keyframes authDrift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(26px, 18px) scale(1.08); }
}

/* ── Tarjeta ──────────────────────────────────────────────────────────────── */
.auth-card {
    position: relative;
    z-index: 1;
    background: rgba(var(--sec-rgb), .12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--sec-rgb), .22);
    border-radius: 22px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .40), 0 0 0 1px rgba(var(--sec-rgb), .06);
    animation: authCardIn .6s cubic-bezier(.16, 1, .3, 1) both .12s;
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(22px) scale(.98); filter: blur(6px); }
    to   { opacity: 1; transform: none; filter: blur(0); }
}

.auth-card.has-error {
    animation: authCardIn .6s cubic-bezier(.16, 1, .3, 1) both, authShake .5s ease .55s;
}

@keyframes authShake {
    10%, 90%     { transform: translateX(-3px); }
    20%, 80%     { transform: translateX(5px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60%     { transform: translateX(8px); }
}

@media (max-width: 480px) {
    .auth-card { padding: 30px 22px; border-radius: 18px; }
}

/* ── Orbe / logo ──────────────────────────────────────────────────────────── */
.auth-orb-wrap {
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
    margin-bottom: 14px;
    animation: authCardIn .6s cubic-bezier(.16, 1, .3, 1) both;
}

/* Sin logo propio: blob líquido animado con las iniciales/ícono de marca */
.auth-orb {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
    box-shadow: 0 14px 34px -10px rgba(var(--brand-rgb), .65);
    animation: authBlobMorph 9s ease-in-out infinite, authFloat 6s ease-in-out infinite;
}
.auth-orb svg { width: 30px; height: 30px; stroke-width: 2; }

@keyframes authBlobMorph {
    0%, 100% { border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; }
    33%      { border-radius: 63% 37% 41% 59% / 51% 62% 38% 49%; }
    66%      { border-radius: 37% 63% 55% 45% / 60% 40% 60% 40%; }
}
@keyframes authFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-7px); }
}

/* Con logo propio: halo suave detrás + flotación leve */
.auth-logo-halo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: authFloat 6s ease-in-out infinite;
}
.auth-logo-halo::before {
    content: "";
    position: absolute;
    inset: -18px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--brand-rgb), .35), transparent 72%);
    filter: blur(16px);
    z-index: -1;
    animation: authGlowPulse 3.4s ease-in-out infinite;
}
.auth-logo-img {
    max-height: 68px;
    max-width: 210px;
    width: auto;
    object-fit: contain;
    display: block;
}
@keyframes authGlowPulse {
    0%, 100% { opacity: .55; transform: scale(1); }
    50%      { opacity: .9;  transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    body.auth-body::before, body.auth-body::after,
    .auth-orb, .auth-logo-halo, .auth-logo-halo::before,
    .auth-card, .auth-orb-wrap {
        animation: none !important;
    }
}

/* ── Encabezado / textos ──────────────────────────────────────────────────── */
.auth-title-wrap { text-align: center; margin-bottom: 28px; }
.auth-title-wrap h1 {
    font-size: 26px;
    color: #fff;
    font-weight: 700;
    letter-spacing: -.3px;
}
.auth-title-wrap h1 span { color: var(--brand-light); }
.auth-title-wrap p {
    color: rgba(255, 255, 255, .68);
    font-size: 13.5px;
    margin-top: 6px;
    line-height: 1.5;
}

/* ── Alertas ──────────────────────────────────────────────────────────────── */
.auth-alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    margin-bottom: 20px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    line-height: 1.4;
}
.auth-alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.auth-alert.is-error { background: rgba(239, 68, 68, .15); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; }
.auth-alert.is-warn  { background: rgba(245, 158, 11, .15); border: 1px solid rgba(245, 158, 11, .3); color: #fcd34d; }
.auth-alert.is-info  { background: rgba(59, 130, 246, .15); border: 1px solid rgba(59, 130, 246, .3); color: #93c5fd; }

/* ── Campos ───────────────────────────────────────────────────────────────── */
.form-group { position: relative; margin-bottom: 18px; }
.form-group label {
    display: block;
    color: rgba(255, 255, 255, .8);
    font-size: 12.5px;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-group .field-icon {
    position: absolute;
    left: 15px;
    top: 39px;
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, .38);
    pointer-events: none;
    transition: color .2s;
}
.form-group:focus-within .field-icon { color: var(--brand-light); }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 12px;
    background: rgba(255, 255, 255, .07);
    color: #f1f5f9;
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--brand-light);
    background: rgba(255, 255, 255, .1);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .22);
}
.form-group input::placeholder { color: rgba(255, 255, 255, .38); }
.hint-small { color: rgba(255, 255, 255, .5); font-size: 11.5px; margin-top: 6px; line-height: 1.5; }

.auth-row {
    display: flex;
    justify-content: flex-end;
    margin: -6px 0 20px;
}
.auth-link {
    color: rgba(var(--brand-rgb), .85);
    font-size: 13px;
    text-decoration: none;
    transition: color .2s;
}
.auth-link:hover { color: var(--brand-light); }

/* ── Botón ────────────────────────────────────────────────────────────────── */
.auth-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(120deg, var(--brand-light), var(--brand-dark));
    background-size: 160% 160%;
    background-position: 0 0;
    color: #fff;
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .25s ease, box-shadow .25s ease, background-position .5s ease, opacity .2s;
}
.auth-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -8px rgba(var(--brand-rgb), .55);
    background-position: 100% 0;
}
.auth-btn:active:not(:disabled) { transform: translateY(0); }
.auth-btn:disabled { cursor: default; opacity: .85; }
.auth-btn .btn-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin .7s linear infinite;
}
.auth-btn.is-loading .btn-label { opacity: .6; }
.auth-btn.is-loading .btn-spinner { display: inline-block; }
@keyframes authSpin { to { transform: rotate(360deg); } }

.auth-btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .18);
    color: rgba(255, 255, 255, .85);
}
.auth-btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, .06);
    box-shadow: none;
    transform: none;
}

/* ── Enlaces auxiliares / pie ─────────────────────────────────────────────── */
.auth-footnote { text-align: center; margin-top: 20px; font-size: 13px; }
.auth-footnote a { color: rgba(255, 255, 255, .5); text-decoration: none; transition: color .2s; }
.auth-footnote a:hover { color: rgba(255, 255, 255, .85); }
.auth-footnote.is-muted a { color: rgba(255, 255, 255, .38); }

/* ── OTP: 6 casillas individuales (2FA) ───────────────────────────────────── */
.otp-boxes { display: flex; gap: 9px; justify-content: center; margin-bottom: 4px; }
.otp-box {
    width: 44px;
    height: 54px;
    text-align: center;
    font-size: 21px;
    font-weight: 700;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .07);
    color: #f1f5f9;
    transition: border-color .2s, box-shadow .2s, background .2s, transform .15s;
}
.otp-box:focus {
    outline: none;
    border-color: var(--brand-light);
    background: rgba(255, 255, 255, .1);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .22);
}
.otp-box.is-filled { border-color: rgba(var(--brand-rgb), .5); }
.otp-boxes.has-error .otp-box {
    border-color: rgba(239, 68, 68, .55);
    animation: authShake .5s ease;
}
@media (max-width: 380px) {
    .otp-box { width: 38px; height: 48px; font-size: 19px; }
    .otp-boxes { gap: 6px; }
}

/* ── Pantalla de éxito (checkmark animado) ───────────────────────────────── */
.auth-success-wrap { text-align: center; }
.auth-check-circle {
    width: 84px;
    height: 84px;
    margin: 0 auto 22px;
    display: block;
    animation: authCheckPop .5s cubic-bezier(.16, 1.4, .4, 1) both .1s;
}
.auth-check-circle .bg {
    fill: none;
    stroke: #22c55e;
    stroke-width: 2.5;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: authCheckRing .5s ease-out forwards .1s;
    filter: drop-shadow(0 0 10px rgba(34, 197, 94, .55));
}
.auth-check-circle .mark {
    fill: none;
    stroke: #22c55e;
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: authCheckMark .35s ease-out forwards .55s;
}
@keyframes authCheckPop {
    from { opacity: 0; transform: scale(.6); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes authCheckRing { to { stroke-dashoffset: 0; } }
@keyframes authCheckMark { to { stroke-dashoffset: 0; } }

/* ── Medidor de fuerza de contraseña ──────────────────────────────────────── */
.strength-bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); margin-top: 8px; overflow: hidden; }
.strength-bar span { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .3s, background .3s; }
