/* ==========================================================================
   UPay — Login page
   ========================================================================== */

:root {
    --primary: #0d5dd0;
    --primary-hover: #0b4fb1;
    --primary-press: #093f8e;
    --primary-soft: #eaf2fd;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e3e8ef;
    --border-strong: #cdd5e0;
    --text: #16202e;
    --text-muted: #5b6675;
    --text-faint: #97a1b0;
    --error: #d93838;
    --error-soft: #fdecec;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 10px 30px rgba(13, 93, 208, 0.10), 0 2px 6px rgba(31, 24, 48, 0.04);
    --ring: 0 0 0 3px rgba(13, 93, 208, 0.20);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: radial-gradient(900px 500px at 90% -10%, rgba(43, 125, 233, 0.14), transparent 60%), radial-gradient(700px 400px at -10% 110%, rgba(13, 93, 208, 0.10), transparent 60%), var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* ---------- Layout ---------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px 32px;
    box-shadow: var(--shadow);
}

/* ---------- Brand ----------------------------------------------------- */
.brand {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2b7de9, #0d5dd0);
    box-shadow: 0 6px 16px rgba(13, 93, 208, 0.25);
}

.brand-logo {
    display: block;
    height: 26px;
    width: auto;
}

/* ---------- Headings -------------------------------------------------- */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.015em;
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 24px;
    font-size: 0.9375rem;
}

/* ---------- Form ------------------------------------------------------ */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

    .field label, .field-label-row label {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text);
    }

input[type="text"],
input[type="email"],
input[type="password"],
input:not([type]) {
    appearance: none;
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9375rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
    color: var(--text-faint);
}

input:hover {
    border-color: #b9b0d0;
}

input:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

input.input-validation-error {
    border-color: var(--error);
}

.input-with-action {
    position: relative;
}

    .input-with-action input {
        padding-right: 44px;
    }

.input-action {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text-faint);
    cursor: pointer;
}

    .input-action:hover {
        color: var(--primary);
        background: var(--primary-soft);
    }

    .input-action svg {
        width: 18px;
        height: 18px;
    }

.link-muted {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

    .link-muted:hover {
        color: var(--primary);
    }

.field-error {
    color: var(--error);
    font-size: 0.8125rem;
    min-height: 0;
}

    .field-error:not(:empty) {
        margin-top: 2px;
    }

.form-error {
    color: var(--error);
    font-size: 0.875rem;
}

    .form-error ul {
        margin: 0;
        padding-left: 18px;
    }

    .form-error:not(.field-validation-valid):not(:empty) {
        background: var(--error-soft);
        border: 1px solid #f3c4c4;
        color: var(--error);
        padding: 10px 14px;
        border-radius: var(--radius);
        margin-bottom: 14px;
    }

/* ---------- Submit button -------------------------------------------- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 46px;
    margin-top: 4px;
    padding: 0 18px;
    font: inherit;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #ffffff;
    background: var(--primary);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}

    .btn-primary:hover {
        background: var(--primary-hover);
    }

    .btn-primary:active {
        background: var(--primary-press);
        transform: translateY(1px);
    }

    .btn-primary:focus-visible {
        outline: none;
        box-shadow: var(--ring);
    }

    .btn-primary:disabled {
        opacity: 0.65;
        cursor: not-allowed;
        transform: none;
    }

.spinner {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: -3px;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Footnote -------------------------------------------------- */
.footnote {
    margin: 22px 0 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ---------- OAuth consent --------------------------------------------- */
.oauth-consent {
    margin: 0 0 24px;
    padding: 18px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.oauth-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 16px;
}

.oauth-node {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border-strong);
    box-shadow: 0 2px 6px rgba(31, 24, 48, 0.06);
    flex: none;
    overflow: hidden;
}

    .oauth-node-app img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 11px;
    }

.oauth-node-initial {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-transform: uppercase;
}

    /* The UPay logo is a horizontal lockup; crop to its left mark (the colorful petals). */
    .oauth-node-upay {
        background: #fff;
    }

        .oauth-node-upay img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: left center;
            display: block;
        }

.oauth-connector {
    width: 40px;
    height: 2px;
    margin: 0 -1px;
    background: repeating-linear-gradient(90deg, var(--border-strong) 0 5px, transparent 5px 10px);
    flex: none;
}

.oauth-perms-title {
    margin: 0 0 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.oauth-perms {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .oauth-perms li {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        font-size: 0.9375rem;
        color: var(--text);
    }

    .oauth-perms svg {
        width: 18px;
        height: 18px;
        flex: none;
        margin-top: 1px;
        color: var(--primary);
    }

.oauth-disclaimer {
    text-align: left;
    font-size: 0.8125rem;
    color: var(--text-faint);
    line-height: 1.45;
}

/* ---------- Small screens -------------------------------------------- */
@media (max-width: 480px) {
    .auth-card {
        padding: 28px 22px 24px;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.375rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
