/* ════════════════════════════════════════
   AUTH — Roll animation (login ⇄ register)
   Form lama: tergulung ke ATAS (tutup)
   Form baru: terbuka DARI ATAS ke bawah
   ════════════════════════════════════════ */

.auth-body {
    display: flex;
    align-items: center;      /* tengah vertikal */
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

/* ─── Aura background ─── */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}
.auth-bg::before,
.auth-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
}
.auth-bg::before {
    width: 420px; height: 420px;
    top: -160px; right: -120px;
    background: rgba(56, 225, 255, 0.10);
    animation: drift-a 14s ease-in-out infinite alternate;
}
.auth-bg::after {
    width: 380px; height: 380px;
    bottom: -150px; left: -110px;
    background: rgba(47, 107, 255, 0.12);
    animation: drift-b 16s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(-50px, 60px) scale(1.15); } }
@keyframes drift-b { to { transform: translate(45px, -55px) scale(1.1); } }

/* ─── Logo ─── */
.auth-wrap {
    width: 100%;
    max-width: 400px;
    animation: auth-in 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes auth-in { from { opacity: 0; transform: translateY(18px); } }

.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-mark {
    width: 62px; height: 62px;
    margin: 0 auto 14px;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #04121c;
    background: linear-gradient(135deg, var(--aurora), var(--aurora-deep));
    box-shadow: 0 14px 40px -10px rgba(56, 225, 255, 0.5);
}
.auth-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.auth-brand em {
    font-style: normal;
    background: linear-gradient(90deg, var(--aurora), var(--aurora-deep));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-tag { font-size: 12px; color: var(--dim); margin-top: 6px; }

/* ─── Card ─── */
.auth-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    padding: 20px 18px;
    overflow: hidden; /* penting buat efek gulung */
}
.auth-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(56,225,255,0.4), transparent 40%, transparent 65%, rgba(47,107,255,0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* ═══ TAB DI LUAR FORM — style sendiri ═══ */
.tab-switch {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 15px;
    padding: 5px;
    margin-bottom: 14px;
}
.tab-switch::before {
    content: '';
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 5px;
    width: calc(50% - 7px);
    border-radius: 11px;
    background: linear-gradient(135deg, var(--aurora), var(--aurora-deep));
    box-shadow: 0 6px 20px -6px rgba(56, 225, 255, 0.6);
    transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.5, 1);
}
.tab-switch[data-tab="register"]::before { transform: translateX(calc(100% + 4px)); }
.tab-switch button {
    position: relative;
    z-index: 1;
    background: transparent;
    border: none;
    color: var(--dim);
    padding: 12px;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.02em;
    transition: color 0.25s;
}
.tab-switch button.active { color: #04121c; }

/* ═══ ROLL ANIMATION ═══
   FORM-nya yang digulung: max-height dianimasikan
   penuh → 0 (tergulung ke atas), 0 → penuh (terbuka dari atas).
   Isi form ikut translateY biar kesan gulungan hidup. */

form#formLoginFields,
form#formRegisterFields {
    opacity: 1;
    transform: translateY(0);
    overflow: hidden;
    transition:
        max-height 0.5s cubic-bezier(0.65, 0, 0.35, 1),
        opacity 0.35s ease,
        transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

/* GULUNG NAIK: tinggi menyusut sampai hilang */
.roll-out {
    max-height: 0 !important;
    opacity: 0;
    transform: translateY(-14px);
}
.roll-out .fg { transform: translateY(-10px); }

/* GULUNG TURUN: state awal tertutup (tinggi 0), dibuka via JS */
.roll-in-init {
    max-height: 0 !important;
    opacity: 0;
    transform: translateY(-12px);
    transition: none !important;   /* dipasang instan, dibuka oleh transisi balik */
}
.roll-in-init .fg { transform: translateY(-8px); }

.fg.hidden { display: none !important; }

/* Password eye */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px; height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--faint);
}
.pw-eye svg { width: 17px; height: 17px; }
.pw-eye:active { color: var(--aurora); }

.forgot { font-size: 11.5px; color: var(--aurora); font-weight: 600; }
.optional { color: var(--faint); font-weight: 400; }

/* Validasi error shake */
.input-error {
    border-color: var(--red) !important;
    animation: shake 0.4s ease;
}
@keyframes shake {
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* ─── Pesan feedback ─── */
.auth-msg {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    animation: msg-in 0.35s ease;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(-6px); } }
.auth-msg.error { background: rgba(255, 92, 114, 0.1); color: var(--red); border: 1px solid rgba(255, 92, 114, 0.25); }
.auth-msg.success { background: var(--aurora-dim); color: var(--aurora); border: 1px solid rgba(56, 225, 255, 0.25); }
.hidden { display: none !important; }

/* ─── Footer ─── */
.auth-terms {
    margin-top: 18px;
    font-size: 11.5px;
    color: var(--faint);
    text-align: center;
    line-height: 1.6;
}
.auth-terms a { color: var(--dim); text-decoration: underline; text-underline-offset: 2px; }
.auth-back { margin-top: 10px; text-align: center; font-size: 12.5px; }
.auth-back a { color: var(--dim); }
.auth-back a:hover { color: var(--aurora); }

/* Loading state tombol */
.btn.loading { opacity: 0.7; pointer-events: none; }
.btn.loading span { visibility: hidden; }
.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    border: 2px solid rgba(4, 18, 28, 0.3);
    border-top-color: #04121c;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .auth-wrap, .auth-bg::before, .auth-bg::after,
    form#formLoginFields, form#formRegisterFields { animation: none !important; transition: none !important; }
}
