@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
    --brand-900: #2e1a63;
    --brand-700: #46228f;
    --brand-600: #512da8;
    --brand-500: #5c6bc0;
    --brand-100: #ede9fe;
    --brand-50: #f5f3ff;
    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --line: #e2e8f0;
    --surface: #f8fafc;
    --radius-lg: 28px;
    --radius-md: 12px;
    --shadow-card: 0 30px 70px -30px rgba(49, 29, 110, .55),
        0 12px 28px -18px rgba(15, 23, 42, .35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    color: var(--ink-700);
    background-color: #eef1fb;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(92, 107, 192, .28), transparent 42%),
        radial-gradient(circle at 88% 82%, rgba(81, 45, 168, .22), transparent 45%),
        linear-gradient(140deg, #f4f6ff 0%, #e9edfb 45%, #eef2ff 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.login-header {
    flex: 0 0 auto;
    padding: 22px 24px 0;
}

.header-inner {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    height: clamp(38px, 6vw, 52px);
    width: auto;
    flex: 0 0 auto;
}

.header-text {
    min-width: 0;
}

.header-title {
    font-size: clamp(14px, 1.5vw, 17px);
    font-weight: 700;
    line-height: 1.25;
    color: #241a4d;
}

.header-subtitle {
    margin-top: 2px;
    font-size: clamp(11px, 1.2vw, 12.5px);
    line-height: 1.45;
    color: var(--ink-500);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.login-main {
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-footer {
    flex: 0 0 auto;
    padding: 18px 24px 22px;
    text-align: center;
}

.footer-inner {
    font-size: 11.5px;
    letter-spacing: .2px;
    color: var(--ink-500);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Card ---------- */
.container {
    position: relative;
    width: 900px;
    max-width: 100%;
    min-height: 600px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    isolation: isolate;
}

.container h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.2px;
    color: #1e1b4b;
}

.container p {
    margin: 14px 0 22px;
    font-size: 13px;
    line-height: 1.7;
    letter-spacing: .2px;
}

.container span {
    font-size: 12px;
    color: var(--ink-400);
}

.container a {
    color: #333;
    text-decoration: none;
}

.container form {
    width: 100%;
    height: 100%;
    padding: 36px 40px;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.form-container {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: transform .6s ease-in-out, opacity .6s ease-in-out;
}

.sign-in {
    left: 0;
    width: 50%;
    z-index: 2;
}

.sign-up {
    left: 0;
    width: 50%;
    opacity: 0;
    z-index: 1;
}

.container.active .sign-in {
    transform: translateX(100%);
}

.container.active .sign-up {
    transform: translateX(100%);
    opacity: 1;
    z-index: 5;
    animation: move .6s;
}

@keyframes move {
    0%, 49.99% {
        opacity: 0;
        z-index: 1;
    }
    50%, 100% {
        opacity: 1;
        z-index: 5;
    }
}

/* ---------- Sign up (panel dekoratif) ---------- */
.sign-up h1 {
    margin-bottom: 2px;
}

.social-icons {
    display: flex;
    gap: 10px;
    margin: 18px 0 12px;
}

.social-icons a {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-500);
    border: 1px solid var(--line);
    border-radius: 50%;
    transition: color .2s, border-color .2s, background-color .2s, transform .2s;
}

.social-icons a:hover {
    color: var(--brand-600);
    border-color: var(--brand-500);
    background-color: var(--brand-50);
    transform: translateY(-1px);
}

.sign-up input {
    width: 100%;
    margin: 6px 0;
    padding: 12px 16px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink-900);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.sign-up input::placeholder {
    color: var(--ink-400);
}

.sign-up input:focus {
    background-color: #fff;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(92, 107, 192, .14);
}

.sign-up button:not(.hidden) {
    width: 100%;
    margin-top: 10px;
    padding: 12px 20px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 60%, var(--brand-700) 100%);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}

.sign-up button:not(.hidden):hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px -14px rgba(81, 45, 168, .8);
}

/* ---------- Sign in ---------- */
.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.login-logo img {
    display: block;
    height: 58px;
    width: auto;
    max-width: 100%;
}

.login-error {
    width: 100%;
    margin-bottom: 14px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    text-align: left;
    color: #b91c1c;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
}

.input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.input-group .input-icon {
    position: absolute;
    left: 16px;
    font-size: 14px;
    color: var(--ink-400);
    pointer-events: none;
    transition: color .2s;
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink-900);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.input-group input::placeholder {
    color: var(--ink-400);
}

.input-group input:focus {
    background-color: #fff;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(92, 107, 192, .14);
}

.input-group:focus-within .input-icon {
    color: var(--brand-600);
}

.input-group-password input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-500);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: color .2s, background-color .2s;
}

.toggle-password:hover {
    color: var(--brand-600);
    background-color: var(--brand-50);
}

.input-group input:-webkit-autofill {
    -webkit-text-fill-color: var(--ink-900);
    box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-out;
}

/* ---------- Captcha ---------- */
.captcha-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 12px;
}

#captcha-image {
    flex: 1 1 auto;
    height: 55px;
    width: 170px;
    max-width: 100%;
    object-fit: cover;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.captcha-refresh {
    flex: 0 0 auto;
    width: 48px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--brand-600);
    background-color: var(--brand-50);
    border: 1px solid var(--brand-100);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color .2s, color .2s, transform .2s;
}

.captcha-refresh:hover {
    color: #fff;
    background-color: var(--brand-600);
    transform: translateY(-1px);
}

.captcha-input-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.captcha-digit {
    width: 100%;
    height: 46px;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    color: var(--ink-900);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.captcha-digit:focus {
    background-color: #fff;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(92, 107, 192, .14);
}

.captcha-digit.filled {
    background-color: var(--brand-50);
    border-color: var(--brand-500);
}

/* ---------- Buttons ---------- */
.btn-login {
    width: 100%;
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 60%, var(--brand-700) 100%);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    box-shadow: 0 14px 24px -12px rgba(81, 45, 168, .75);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, opacity .2s;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 28px -12px rgba(81, 45, 168, .85);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-desc {
    margin-top: 16px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--ink-400);
    text-align: center;
}

/* ---------- Toggle panel ---------- */
.toggle-container {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    overflow: hidden;
    z-index: 1000;
    border-radius: 150px 0 0 120px;
    transition: transform .6s ease-in-out, border-radius .6s ease-in-out;
}

.container.active .toggle-container {
    transform: translateX(-100%);
    border-radius: 0 150px 120px 0;
}

.toggle {
    position: relative;
    left: -100%;
    width: 200%;
    height: 100%;
    color: #fff;
    background: linear-gradient(135deg, #5c6bc0 0%, #512da8 55%, #3b1d7f 100%);
    transition: transform .6s ease-in-out;
}

.container.active .toggle {
    transform: translateX(50%);
}

.toggle-panel {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    transform: translateX(0);
    transition: transform .6s ease-in-out;
}

.toggle-panel::before {
    content: '';
    position: absolute;
    inset: -40% -20%;
    background:
        radial-gradient(circle at 72% 18%, rgba(255, 255, 255, .18), transparent 52%),
        radial-gradient(circle at 18% 92%, rgba(255, 255, 255, .10), transparent 50%);
    pointer-events: none;
}

.toggle-panel > * {
    position: relative;
    z-index: 1;
}

.toggle-panel h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.2px;
    color: #fff;
}

.toggle-panel p {
    margin: 14px 0 26px;
    font-size: 13px;
    line-height: 1.75;
    color: rgba(255, 255, 255, .86);
}

.container button.hidden {
    padding: 11px 40px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: #fff;
    background-color: transparent;
    border: 1.5px solid rgba(255, 255, 255, .75);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .2s, color .2s, transform .2s;
}

.container button.hidden:hover {
    color: var(--brand-700);
    background-color: #fff;
    transform: translateY(-1px);
}

.toggle-left {
    left: 0;
    transform: translateX(-200%);
}

.container.active .toggle-left {
    transform: translateX(0);
}

.toggle-right {
    right: 0;
    transform: translateX(0);
}

.container.active .toggle-right {
    transform: translateX(200%);
}

/* ---------- Focus visibility ---------- */
:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

/* ---------- Tablet / Mobile ---------- */
@media (max-width: 920px) {
    .container {
        width: 460px;
        min-height: 0;
    }

    .sign-up,
    .toggle-container {
        display: none;
    }

    .sign-in {
        position: relative;
        width: 100%;
        height: auto;
        transform: none !important;
    }

    .container form {
        height: auto;
        padding: 36px 32px 32px;
    }

    .login-logo img {
        height: 52px;
    }

    .login-main {
        padding: 20px 18px;
    }
}

@media (max-width: 560px) {
    .login-header {
        padding: 16px 18px 0;
    }

    .header-inner {
        gap: 10px;
    }

    .header-subtitle {
        -webkit-line-clamp: 1;
    }

    .login-main {
        padding: 14px;
    }

    .container {
        border-radius: 22px;
    }

    .container form {
        padding: 30px 20px 26px;
    }

    .container h1 {
        font-size: 20px;
    }

    .login-logo {
        margin-bottom: 16px;
    }

    .login-logo img {
        height: 46px;
    }

    .input-group input {
        padding: 13px 14px 13px 42px;
        font-size: 13.5px;
    }

    .input-group .input-icon {
        left: 14px;
        font-size: 13px;
    }

    .captcha-row {
        gap: 8px;
    }

    #captcha-image {
        height: 50px;
    }

    .captcha-refresh {
        width: 44px;
        height: 50px;
    }

    .captcha-input-group {
        gap: 6px;
        margin-bottom: 16px;
    }

    .captcha-digit {
        height: 44px;
        font-size: 16px;
        border-radius: 9px;
    }

    .login-footer {
        padding: 14px 18px 18px;
    }
}

@media (max-width: 380px) {
    .container form {
        padding: 26px 16px 22px;
    }

    .captcha-input-group {
        gap: 5px;
    }

    .captcha-digit {
        height: 40px;
        font-size: 15px;
    }

    .captcha-refresh {
        width: 40px;
    }

    .btn-login {
        padding: 13px 16px;
        font-size: 12.5px;
    }
}

/* Layar pendek (laptop kecil / landscape) */
@media (min-width: 921px) and (max-height: 760px) {
    .login-header {
        padding-top: 12px;
    }

    .container {
        min-height: 540px;
    }

    .container form {
        padding: 24px 40px;
    }

    .login-logo {
        margin-bottom: 12px;
    }

    .login-logo img {
        height: 46px;
    }

    .input-group {
        margin-bottom: 10px;
    }

    .captcha-input-group {
        margin-bottom: 14px;
    }

    .login-footer {
        padding-top: 12px;
    }
}

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