@import url("./ui-tokens.css");

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-width: 0;
    min-height: 100vh;
}

body.login-body {
    --login-blue: #2f74f5;
    --login-blue-deep: #153572;
    --login-blue-soft: #6ba2ff;
    --login-text: #17213a;
    --login-muted: #5a6a8d;
    --login-border: #cfdaf0;
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: clamp(12px, 2.4vw, 28px);
    overflow: hidden;
    background:
        radial-gradient(circle at 7% 10%, rgba(119, 171, 245, 0.26) 0 46px, transparent 47px),
        radial-gradient(circle at 85% 10%, rgba(128, 179, 255, 0.24) 0 44px, transparent 45px),
        radial-gradient(circle at 96% 48%, rgba(77, 139, 236, 0.18) 0 26px, transparent 27px),
        linear-gradient(135deg, #eaf4ff 0%, #f7fbff 43%, #e1f0ff 100%);
    color: var(--login-text);
    font-family: var(--ui-font-family);
    color-scheme: light;
}

body.login-body::before,
body.login-body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body.login-body::before {
    background:
        radial-gradient(circle, rgba(107, 162, 255, 0.18) 0 6px, transparent 7px) 10% 0 / 32px 32px,
        radial-gradient(circle, rgba(47, 116, 245, 0.15) 0 6px, transparent 7px) 96% 8% / 34px 34px;
    opacity: 0.95;
}

body.login-body::after {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.1)),
        radial-gradient(ellipse at 11% 80%, rgba(69, 133, 235, 0.22) 0 15%, transparent 35%),
        radial-gradient(ellipse at 88% 80%, rgba(69, 133, 235, 0.24) 0 16%, transparent 38%);
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.8), transparent 34%, transparent 66%, rgba(0, 0, 0, 0.8));
}

.login-shell {
    position: relative;
    z-index: 1;
    width: min(100%, 860px);
}

.login-shell::before,
.login-shell::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    opacity: 0.62;
    filter: drop-shadow(0 22px 24px rgba(82, 136, 224, 0.2));
}

.login-shell::before {
    left: max(18px, calc(50vw - 790px));
    bottom: 7vh;
    width: min(310px, 25vw);
    aspect-ratio: 1.24;
    border-radius: 22px 22px 12px 12px;
    background:
        linear-gradient(180deg, rgba(82, 142, 237, 0.72) 0 18%, transparent 18%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.98) 0 25%, rgba(213, 232, 255, 0.98) 25% 50%, rgba(255, 255, 255, 0.98) 50% 75%, rgba(213, 232, 255, 0.98) 75%) 0 20% / 100% 26% no-repeat,
        linear-gradient(180deg, rgba(218, 235, 255, 0.88), rgba(163, 202, 255, 0.76));
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.44);
}

.login-shell::after {
    right: max(20px, calc(50vw - 780px));
    bottom: 10vh;
    width: min(280px, 23vw);
    aspect-ratio: 1.08;
    border: 10px solid rgba(85, 143, 234, 0.62);
    border-top-width: 32px;
    border-radius: 22px;
    background:
        linear-gradient(145deg, transparent 0 47%, rgba(47, 116, 245, 0.38) 48% 51%, transparent 52% 100%),
        repeating-linear-gradient(180deg, rgba(66, 126, 225, 0.12) 0 11px, transparent 12px 28px),
        rgba(235, 245, 255, 0.72);
}

.login-panel {
    position: relative;
    overflow: hidden;
    width: min(100%, 860px);
    margin: 0 auto;
    padding: clamp(22px, 3.8vw, 42px) clamp(24px, 5vw, 64px);
    border: 1px solid rgba(198, 214, 240, 0.92);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 32px 80px rgba(64, 117, 204, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px) saturate(1.08);
    -webkit-backdrop-filter: blur(18px) saturate(1.08);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 3vw, 30px);
    margin-bottom: 22px;
    text-align: left;
}

.login-logo {
    width: clamp(78px, 10vw, 120px);
    height: clamp(78px, 10vw, 120px);
    flex: 0 0 auto;
    object-fit: contain;
    border-radius: 22px;
    filter: drop-shadow(0 16px 22px rgba(45, 111, 230, 0.2));
}

.login-brand h1 {
    margin: 0;
    color: #102d70;
    font-size: clamp(44px, 6.4vw, 64px);
    font-weight: 950;
    letter-spacing: 0;
    line-height: 1;
}

.login-brand p {
    margin: 10px 0 0;
    color: var(--login-muted);
    font-size: clamp(15px, 1.7vw, 19px);
    font-weight: 700;
    line-height: 1.4;
}

.login-form {
    display: grid;
    gap: 13px;
}

.login-form[hidden] {
    display: none;
}

.login-binding-intro h2 {
    margin: 0;
    color: #153572;
    font-size: 24px;
    line-height: 1.25;
}

.login-binding-intro p {
    margin: 7px 0 3px;
    color: var(--login-muted);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.55;
}

.login-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0 0 18px;
    padding: 4px;
    border: 1px solid #cbd9ef;
    border-radius: 10px;
    background: #eef4fd;
}

.login-mode-tabs button {
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #4a5d82;
    font: inherit;
    font-size: 16px;
    font-weight: 850;
    cursor: pointer;
}

.login-mode-tabs button[aria-selected="true"] {
    background: #ffffff;
    color: #185fcf;
    box-shadow: 0 2px 8px rgba(46, 92, 163, 0.14);
}

.login-mode-tabs button:focus-visible {
    outline: 3px solid rgba(47, 116, 245, 0.24);
    outline-offset: 2px;
}

.login-field-help {
    color: #667796;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.45;
}

.login-field {
    display: grid;
    gap: 9px;
    color: var(--login-text);
    font-size: 16px;
    font-weight: 850;
}

.login-field input,
.login-field select {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--login-border);
    border-radius: 8px;
    background: #ffffff;
    color: #14213d;
    font: inherit;
    font-size: 17px;
    font-weight: 650;
    line-height: 1.2;
    outline: none;
    transition:
        border-color var(--ui-motion-fast) var(--ui-ease-standard),
        box-shadow var(--ui-motion-medium) var(--ui-ease-standard),
        background var(--ui-motion-fast) var(--ui-ease-standard);
}

.login-field select {
    padding: 0 44px 0 72px;
    cursor: pointer;
    appearance: none;
    background:
        linear-gradient(90deg, #f3f7ff 0 56px, transparent 56px),
        linear-gradient(45deg, transparent 45%, #243b6e 46% 54%, transparent 55%) right 20px center / 10px 10px no-repeat,
        #ffffff;
}

.login-input-shell {
    position: relative;
    display: block;
}

.login-input-shell::before,
.login-field:has(select)::after {
    content: "";
    position: absolute;
    left: 18px;
    top: 50%;
    width: 24px;
    height: 24px;
    transform: translateY(-50%);
    background-color: var(--login-blue-soft);
    pointer-events: none;
}

.login-field:has(select) {
    position: relative;
}

.login-field:has(select)::after {
    top: auto;
    bottom: 13px;
    transform: none;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7h14M5 12h14M5 17h14' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-input-shell[data-login-icon="server"]::before {
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-18c2.4 2.3 3.6 5.3 3.6 9S14.4 18.7 12 21m0-18c-2.4 2.3-3.6 5.3-3.6 9S9.6 18.7 12 21M3.6 9h16.8M3.6 15h16.8' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-input-shell[data-login-icon="user"]::before {
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm7 8a7 7 0 0 0-14 0' fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-input-shell[data-login-icon="lock"]::before {
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6z' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-input-shell[data-login-icon="key"]::before {
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='12' r='4' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m11.5 10.5 8-8M16 6l2 2M14 8l2 2' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-input-shell[data-login-icon="shield"]::before {
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3 5 6v5c0 4.7 2.8 8.1 7 10 4.2-1.9 7-5.3 7-10V6l-7-3Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='m9 12 2 2 4-4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(132px, auto);
    gap: 10px;
    align-items: stretch;
}

.login-code-send {
    min-height: 50px;
    border: 1px solid #9eb9e8;
    border-radius: 8px;
    padding: 0 18px;
    background: #f5f9ff;
    color: #185fcf;
    font: inherit;
    font-size: 15px;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
    transition:
        border-color var(--ui-motion-fast) var(--ui-ease-standard),
        background var(--ui-motion-fast) var(--ui-ease-standard),
        color var(--ui-motion-fast) var(--ui-ease-standard),
        box-shadow var(--ui-motion-fast) var(--ui-ease-standard);
}

.login-code-send:hover:not(:disabled),
.login-code-send:focus-visible {
    border-color: #2f74f5;
    background: #eaf2ff;
    color: #124fae;
    outline: none;
    box-shadow: 0 0 0 4px rgba(47, 116, 245, 0.14);
}

.login-code-send:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.login-input-shell input {
    padding: 0 54px 0 72px;
}

.login-password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 34px;
    height: 34px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #46618e;
    cursor: pointer;
}

.login-password-toggle::before {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    margin: 5px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 12s3.3-6 9-6 9 6 9 6-3.3 6-9 6-9-6-9-6Zm9 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-field input:hover,
.login-field select:hover {
    border-color: #abc1e8;
}

.login-field input:focus,
.login-field select:focus,
.login-password-toggle:focus-visible {
    border-color: rgba(47, 116, 245, 0.66);
    box-shadow: 0 0 0 4px rgba(47, 116, 245, 0.14);
}

.login-field input:-webkit-autofill {
    -webkit-text-fill-color: #14213d;
    box-shadow: 0 0 0 1000px #ffffff inset;
    transition: background-color 9999s ease-in-out 0s;
}

.login-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #405278;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
}

.login-check input {
    width: 22px;
    height: 22px;
    accent-color: var(--login-blue);
    cursor: pointer;
}

.login-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.login-inline-action {
    justify-self: end;
    min-height: 36px;
    padding: 4px 2px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #185fcf;
    font: inherit;
    font-size: 14px;
    font-weight: 850;
    cursor: pointer;
}

.login-inline-action:hover,
.login-inline-action:focus-visible {
    color: #0d4fac;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.login-inline-action:focus-visible {
    outline: 3px solid rgba(47, 116, 245, 0.22);
    outline-offset: 2px;
}

.login-actions {
    display: grid;
    gap: 11px;
    margin-top: 0;
}

.login-submit,
.login-secondary {
    min-height: 52px;
    padding: 0 18px;
    border-radius: 8px;
    font: inherit;
    font-size: 19px;
    font-weight: 900;
    letter-spacing: 0;
    cursor: pointer;
    transition:
        transform var(--ui-motion-fast) var(--ui-ease-standard),
        border-color var(--ui-motion-fast) var(--ui-ease-standard),
        background var(--ui-motion-fast) var(--ui-ease-standard),
        box-shadow var(--ui-motion-medium) var(--ui-ease-standard),
        color var(--ui-motion-fast) var(--ui-ease-standard);
}

.login-submit {
    border: 1px solid #2368e8;
    background: linear-gradient(180deg, #2f7dff 0%, #1964ed 100%);
    color: #ffffff;
    box-shadow: 0 14px 26px rgba(31, 104, 238, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.login-submit:hover,
.login-submit:focus-visible {
    transform: translateY(-1px);
    border-color: #1558d4;
    background: linear-gradient(180deg, #438bff 0%, #1d6df7 100%);
    box-shadow: 0 18px 34px rgba(31, 104, 238, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.login-submit:focus-visible,
.login-secondary:focus-visible {
    outline: none;
}

.login-submit:disabled,
.login-secondary:disabled {
    cursor: wait;
    opacity: 0.64;
    transform: none;
}

.login-secondary {
    border: 1px solid #b9cdf1;
    background: #ffffff;
    color: #1d73ff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.login-secondary:hover,
.login-secondary:focus-visible {
    border-color: #8fb4f4;
    background: #f5f9ff;
    color: #0d5fe8;
    transform: translateY(-1px);
}

.login-status {
    padding: 12px 14px;
    border: 1px solid #c9d8f1;
    border-radius: 8px;
    background: #f7faff;
    color: #405278;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.55;
}

.login-status[data-tone="success"] {
    background: #eefbf4;
    border-color: #a7e6c2;
    color: #16643d;
}

.login-status[data-tone="danger"] {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #a41f38;
}

.login-status[data-tone="info"] {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4f9d;
}

@media (max-width: 780px) {
    body.login-body {
        align-items: start;
        padding: 14px;
        overflow-y: auto;
    }

    .login-shell::before,
    .login-shell::after {
        display: none;
    }

    .login-panel {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .login-brand {
        gap: 14px;
        justify-content: flex-start;
        margin-bottom: 22px;
    }

    .login-logo {
        width: 82px;
        height: 82px;
        border-radius: 20px;
    }

    .login-brand h1 {
        font-size: clamp(38px, 12vw, 54px);
    }

    .login-brand p {
        margin-top: 8px;
        font-size: 15px;
    }

    .login-field {
        font-size: 15px;
    }

    .login-field input,
    .login-field select {
        min-height: 50px;
        font-size: 16px;
    }

    .login-submit,
    .login-secondary {
        min-height: 52px;
        font-size: 18px;
    }
}

@media (min-width: 781px) and (max-height: 760px) {
    body.login-body {
        padding: 10px;
    }

    .login-panel {
        padding: 20px 56px;
        border-radius: 24px;
    }

    .login-brand {
        gap: 18px;
        margin-bottom: 14px;
    }

    .login-logo {
        width: 82px;
        height: 82px;
        border-radius: 18px;
    }

    .login-brand h1 {
        font-size: 50px;
    }

    .login-brand p {
        margin-top: 6px;
        font-size: 15px;
    }

    .login-form {
        gap: 9px;
    }

    .login-field {
        gap: 5px;
        font-size: 14px;
    }

    .login-field input,
    .login-field select {
        min-height: 44px;
        font-size: 16px;
    }

    .login-field:has(select)::after {
        bottom: 10px;
    }

    .login-check {
        gap: 8px;
        font-size: 15px;
    }

    .login-check input {
        width: 18px;
        height: 18px;
    }

    .login-actions {
        gap: 8px;
    }

    .login-submit,
    .login-secondary {
        min-height: 46px;
        font-size: 17px;
    }
}

@media (max-width: 430px) {
    .login-brand {
        align-items: flex-start;
    }

    .login-logo {
        width: 66px;
        height: 66px;
    }

    .login-input-shell input,
    .login-field select {
        padding-left: 56px;
    }

    .login-code-row {
        grid-template-columns: 1fr;
    }

    .login-code-send {
        width: 100%;
    }

    .login-options-row {
        align-items: flex-start;
    }
}

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