@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
    --auth-primary: #4669fa;
    --auth-primary-soft: #eef2ff;
    --auth-ink: #0f172a;
    --auth-muted: #64748b;
    --auth-line: #dfe5ee;
    --auth-surface: #ffffff;
    --auth-visual: #f1f5f9;
    --auth-danger: #dc2626;
    --auth-radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.dashcode-auth {
    min-height: 100vh;
    margin: 0;
    color: var(--auth-ink);
    background: var(--auth-surface);
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    font-size: 0.875rem;
    -webkit-font-smoothing: antialiased;
}

body.dashcode-auth,
body.dashcode-auth .form-control,
body.dashcode-auth .form-select,
body.dashcode-auth .btn {
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    font-size: 0.875rem;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(420px, 1.04fr) minmax(520px, 0.96fr);
}

.auth-visual {
    position: relative;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    overflow: hidden;
    padding: clamp(2rem, 4.25vw, 4.75rem);
    background: var(--auth-visual);
    isolation: isolate;
}

.auth-visual::before,
.auth-visual::after {
    position: absolute;
    z-index: -1;
    content: '';
    border-radius: 50%;
}

.auth-visual::before {
    top: -190px;
    right: -150px;
    width: 430px;
    height: 430px;
    background: rgba(70, 105, 250, 0.075);
}

.auth-visual::after {
    bottom: -240px;
    left: -140px;
    width: 520px;
    height: 520px;
    border: 1px solid rgba(70, 105, 250, 0.14);
    box-shadow: 0 0 0 50px rgba(70, 105, 250, 0.025), 0 0 0 100px rgba(70, 105, 250, 0.018);
}

.auth-brand,
.auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.78rem;
    color: var(--auth-ink);
    text-decoration: none;
}

.auth-brand:hover,
.auth-mobile-brand:hover {
    color: var(--auth-ink);
}

.auth-brand-mark {
    display: grid;
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    place-items: center;
    overflow: hidden;
    background: #111827;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
}

.auth-brand-mark img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    filter: grayscale(1) contrast(1.12);
    border-radius: 50%;
}

.auth-brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.auth-brand-name {
    color: var(--auth-ink);
    font-size: 1rem;
    font-weight: 700;
}

.auth-brand-unit {
    margin-top: 0.22rem;
    color: var(--auth-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

.auth-visual-copy {
    position: relative;
    z-index: 2;
    max-width: 540px;
    margin-top: clamp(3.5rem, 8vh, 7.5rem);
}

.auth-visual-copy h1 {
    margin: 0;
    color: var(--auth-ink);
    font-size: clamp(2rem, 3.2vw, 3.35rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.auth-visual-copy h1 strong {
    display: block;
    color: inherit;
    font-weight: 700;
}

.auth-visual-copy p {
    max-width: 470px;
    margin: 1.25rem 0 0;
    color: var(--auth-muted);
    font-size: 1rem;
    line-height: 1.8;
}

.auth-illustration {
    position: absolute;
    right: clamp(-3.5rem, -1vw, -1rem);
    bottom: clamp(0.5rem, 2.5vh, 1.75rem);
    z-index: 1;
    width: min(90%, 720px);
    max-height: 61vh;
    object-fit: contain;
    object-position: right bottom;
    -webkit-mask-image: radial-gradient(ellipse 86% 82% at 55% 56%, #000 62%, transparent 100%);
    mask-image: radial-gradient(ellipse 86% 82% at 55% 56%, #000 62%, transparent 100%);
    pointer-events: none;
}

.auth-illustration-register {
    width: min(92%, 740px);
}

.auth-visual-footer {
    position: relative;
    z-index: 2;
    margin-top: auto;
    color: #94a3b8;
    font-size: 0.72rem;
}

.auth-form-panel {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    padding: 2rem clamp(2rem, 6vw, 6.5rem) 1.3rem;
    background: var(--auth-surface);
}

.auth-mobile-brand {
    display: none;
}

.auth-form-stage {
    display: flex;
    width: 100%;
    max-width: 430px;
    flex: 1;
    align-items: center;
    margin: auto;
    padding: 2.5rem 0;
}

.auth-box {
    width: 100%;
}

.auth-heading {
    margin-bottom: 2rem;
    text-align: center;
}

.auth-heading h1 {
    margin: 0;
    color: var(--auth-ink);
    font-size: 1.65rem;
    font-weight: 600;
    line-height: 1.35;
}

.auth-heading p {
    margin: 0.6rem 0 0;
    color: var(--auth-muted);
    font-size: 0.9rem;
    line-height: 1.65;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field {
    margin: 0;
}

.auth-field .form-label {
    display: block;
    margin-bottom: 0.48rem;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
}

.auth-control {
    position: relative;
}

.auth-control > i {
    position: absolute;
    top: 50%;
    left: 0.9rem;
    z-index: 2;
    color: #94a3b8;
    font-size: 1.05rem;
    line-height: 1;
    transform: translateY(-50%);
    pointer-events: none;
}

body.dashcode-auth .auth-control .form-control,
body.dashcode-auth .auth-control .form-select {
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 2.75rem 0.65rem 2.65rem;
    color: #334155;
    background-color: #fff;
    border: 1px solid var(--auth-line);
    border-radius: 6px;
    outline: none;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.dashcode-auth .auth-control .form-control::placeholder {
    color: #a0aec0;
}

body.dashcode-auth .auth-control .form-control:focus,
body.dashcode-auth .auth-control .form-select:focus {
    color: #334155;
    background-color: #fff;
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(70, 105, 250, 0.12);
}

body.dashcode-auth .auth-control .form-control.is-invalid,
body.dashcode-auth .auth-control .form-select.is-invalid {
    border-color: #ef4444;
}

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.65rem;
    z-index: 3;
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #94a3b8;
    background: transparent;
    border: 0;
    border-radius: 5px;
    transform: translateY(-50%);
}

.auth-password-toggle:hover,
.auth-password-toggle:focus-visible {
    color: var(--auth-primary);
    background: var(--auth-primary-soft);
    outline: none;
}

.invalid-feedback {
    margin-top: 0.35rem;
    color: var(--auth-danger);
    font-size: 0.74rem;
}

.auth-form-options {
    display: flex;
    min-height: 28px;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.1rem;
}

.auth-form-options .form-check {
    display: flex;
    min-height: 0;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.auth-form-options .form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    border-color: #cbd5e1;
    border-radius: 4px;
}

.auth-form-options .form-check-input:checked {
    background-color: var(--auth-primary);
    border-color: var(--auth-primary);
}

.auth-form-options .form-check-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(70, 105, 250, 0.12);
}

.auth-form-options .form-check-label {
    color: var(--auth-muted);
    font-size: 0.78rem;
    cursor: pointer;
}

body.dashcode-auth .auth-submit {
    display: inline-flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    margin-top: 0.35rem;
    padding: 0.65rem 1rem;
    color: #fff;
    background: var(--auth-ink);
    border: 1px solid var(--auth-ink);
    border-radius: 6px;
    font-size: 0.84rem;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.13);
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

body.dashcode-auth .auth-submit:hover,
body.dashcode-auth .auth-submit:focus {
    color: #fff;
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

body.dashcode-auth .auth-submit:active {
    transform: translateY(1px);
}

body.dashcode-auth .auth-submit:disabled {
    cursor: wait;
    opacity: 0.7;
}

.auth-switch {
    margin: 1.75rem 0 0;
    color: var(--auth-muted);
    font-size: 0.79rem;
    line-height: 1.6;
    text-align: center;
}

.auth-switch a {
    color: var(--auth-ink);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    color: var(--auth-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-success {
    text-align: center;
}

.auth-success-icon {
    display: grid;
    width: 72px;
    height: 72px;
    place-items: center;
    margin: 0 auto 1.5rem;
    color: #16a34a;
    background: #ecfdf3;
    border-radius: 50%;
    font-size: 2.4rem;
}

.auth-success h1 {
    margin: 0;
    color: var(--auth-ink);
    font-size: 1.55rem;
    font-weight: 600;
}

.auth-success p {
    margin: 0.8rem 0 1.75rem;
    color: var(--auth-muted);
    line-height: 1.75;
}

body.dashcode-auth .auth-success .btn {
    min-height: 42px;
    padding: 0.55rem 1rem;
    color: #fff;
    background: var(--auth-ink);
    border-color: var(--auth-ink);
    border-radius: 6px;
    font-weight: 600;
}

.auth-page-footer {
    color: #94a3b8;
    font-size: 0.7rem;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 1099.98px) {
    .auth-shell {
        grid-template-columns: minmax(340px, 0.88fr) minmax(500px, 1.12fr);
    }

    .auth-visual {
        padding: 2.25rem;
    }

    .auth-visual-copy h1 {
        font-size: 2.15rem;
    }

    .auth-illustration {
        right: -2.5rem;
        width: 94%;
    }
}

@media (max-width: 899.98px) {
    body.dashcode-auth {
        background: var(--auth-visual);
    }

    .auth-shell {
        display: block;
    }

    .auth-visual {
        display: none;
    }

    .auth-form-panel {
        min-height: 100vh;
        padding: 1.5rem clamp(1.1rem, 7vw, 4rem) 1rem;
        background: linear-gradient(180deg, var(--auth-visual) 0, var(--auth-visual) 31%, #fff 31%, #fff 100%);
    }

    .auth-mobile-brand {
        display: inline-flex;
        align-self: flex-start;
    }

    .auth-form-stage {
        max-width: 470px;
        align-items: flex-start;
        margin-top: clamp(2rem, 7vh, 4rem);
        padding: 2rem;
        background: #fff;
        border: 1px solid #e6ebf2;
        border-radius: var(--auth-radius);
        box-shadow: 0 18px 45px rgba(15, 23, 42, 0.09);
    }
}

@media (max-width: 575.98px) {
    .auth-form-panel {
        padding: 1.1rem 0.9rem 0.9rem;
        background: #fff;
    }

    .auth-brand-mark {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .auth-brand-mark img {
        width: 32px;
        height: 32px;
    }

    .auth-brand-name {
        font-size: 0.9rem;
    }

    .auth-brand-unit {
        font-size: 0.65rem;
    }

    .auth-form-stage {
        max-width: none;
        margin-top: 1.75rem;
        padding: 1.1rem 0.2rem 1.5rem;
        border: 0;
        box-shadow: none;
    }

    .auth-heading {
        margin-bottom: 1.65rem;
        text-align: left;
    }

    .auth-heading h1 {
        font-size: 1.45rem;
    }

    .auth-heading p {
        font-size: 0.83rem;
    }

    .auth-page-footer {
        padding-top: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.dashcode-auth *,
    body.dashcode-auth *::before,
    body.dashcode-auth *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
