/* Login / account pages — standalone styling for the anonymous _LoginLayout.
   Reuses the shared theme variables so the sign-in screen matches the app shell. */

.login-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Classic (AntDesign blue) is the default theme. --page-bg comes from site.css and is
       overridden per theme in theme-variables.css, so it still shows through while the photo
       loads and anywhere the photo cannot cover. */
    background-color: var(--page-bg, #4e73cb);
    /* The gradient sits above the photo and darkens it just enough to keep the white card edge
       and the footer text readable regardless of what part of the image is in view. */
    background-image: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
                      url("../img/HomeBackground1.jpg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.login-page main {
    flex: 1 1 auto;
    display: flex;
}

.login-shell {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--pop-bg, #ffffff);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    padding: 40px 36px 32px;
}

.login-brand {
    text-align: center;
    margin-bottom: 20px;
}

/* The mark is roughly 5:3 (892×537 viewBox), so height is the dimension worth pinning — 84px
   lands it at ~140px wide, well inside the card's 328px content width at any card size. */
.login-logo {
    display: block;
    height: 84px;
    width: auto;
    max-width: 100%;
    margin: 0 auto;
}

/* The mark is near-black green (#06381d) and the card turns #1c2338 under the dark theme, where
   it would all but disappear. A light plate keeps the brand colours intact rather than filtering
   or inverting them. Only the dark theme needs this — every other theme's card is white. */
[data-theme="dark"] .login-logo {
    /* content-box so the plate grows around the mark instead of the inherited border-box
       sizing eating the padding out of the 84px and shrinking it below the other themes. */
    box-sizing: content-box;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 8px;
}

.login-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
    color: var(--pop-title, rgba(0, 0, 0, 0.88));
    text-align: center;
}

.login-subtitle {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--pop-muted, rgba(0, 0, 0, 0.45));
    text-align: center;
}

.login-field {
    margin-bottom: 16px;
}

.login-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
}

.login-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
    background: #ffffff;
    border: 1px solid var(--pop-border, #d9d9d9);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
    outline: none;
    border-color: var(--btn-accent-bg, #1890ff);
    box-shadow: 0 0 0 2px var(--btn-accent-shadow, rgba(24, 144, 255, 0.35));
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.login-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
    cursor: pointer;
    user-select: none;
}

.login-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--btn-accent-bg, #1890ff);
    cursor: pointer;
}

.login-checkbox input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--btn-accent-shadow, rgba(24, 144, 255, 0.35));
}

.login-button {
    width: 100%;
    margin-top: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--btn-accent-color, #ffffff);
    background: var(--btn-accent-bg, #1890ff);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-button:hover {
    background: var(--btn-accent-hover-bg, #40a9ff);
}

/* Busy state, set by login.js on submit. The sign-in round trip hits the database and then
   loads the app shell, so the button carries the progress rather than leaving the form looking
   untouched. Keeps the accent fill — greying out reads as "rejected"; the spinner is the signal.
   :hover and :disabled are matched too, both of which apply to the same element while busy. */
.login-button.is-busy,
.login-button.is-busy:hover,
.login-button.is-busy:disabled {
    background: var(--btn-accent-bg, #1890ff);
    color: var(--btn-accent-color, #ffffff);
    cursor: progress;
}

/* currentColor keeps the ring on the button's own foreground token, so it tracks every theme. */
.login-button.is-busy::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: login-spin 0.7s linear infinite;
}

@keyframes login-spin {
    to { transform: rotate(360deg); }
}

/* Still turns — a frozen ring would read as "stuck" — just slowly enough not to provoke. */
@media (prefers-reduced-motion: reduce) {
    .login-button.is-busy::before {
        animation-duration: 2.4s;
    }
}

/* ── Single sign-on (below the password form) ──────────────────────────────────
   A secondary button: the outline keeps the accent fill for the primary Sign In. */
.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 16px;
    font-size: 12px;
    color: var(--pop-muted, rgba(0, 0, 0, 0.45));
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1 1 auto;
    border-top: 1px solid var(--pop-border, #d9d9d9);
}

.login-sso-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
    background: transparent;
    border: 1px solid var(--pop-border, #d9d9d9);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-sso-button:hover,
.login-sso-button:focus-visible {
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
    text-decoration: none;
    border-color: var(--btn-accent-bg, #1890ff);
}

.login-sso-icon {
    flex: 0 0 auto;
    display: block;
}

.login-sso-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--btn-accent-shadow, rgba(24, 144, 255, 0.35));
}

/* ── Password rules, strength and match (Change Password) ─────────────────────
   State classes come from password-strength.js. Only the markers and bar carry the status
   colours, which are under 4.5:1 on the white card; the words stay in the text colour. */
.login-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.login-strength[hidden] {
    display: none;
}

.login-strength-bar {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.login-strength-bar span {
    height: 4px;
    border-radius: 2px;
    background: var(--pop-border, #d9d9d9);
    transition: background 0.2s;
}

.login-strength[data-level="weak"]   .login-strength-bar span:nth-child(-n+1) { background: var(--status-danger); }
.login-strength[data-level="fair"]   .login-strength-bar span:nth-child(-n+2) { background: var(--pop-icon-warning); }
.login-strength[data-level="good"]   .login-strength-bar span:nth-child(-n+3) { background: var(--status-success); }
.login-strength[data-level="strong"] .login-strength-bar span:nth-child(-n+4) { background: var(--status-success); }

.login-strength-label {
    flex: 0 0 auto;
    min-width: 96px;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
}

.login-rules {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    font-size: 12px;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
}

.login-rules li,
.login-match {
    position: relative;
    padding-left: 18px;
    line-height: 1.7;
}

.login-rules li::before,
.login-match::before {
    position: absolute;
    left: 2px;
    font-weight: 700;
}

.login-rules li::before {
    content: "\2022";
    color: var(--pop-muted, rgba(0, 0, 0, 0.45));
}

.login-rules li.is-met::before {
    content: "\2713";
    color: var(--status-success);
}

.login-match {
    margin-top: 6px;
    font-size: 12px;
    color: var(--pop-text, rgba(0, 0, 0, 0.88));
}

.login-match.is-match::before    { content: "\2713"; color: var(--status-success); }
.login-match.is-mismatch::before { content: "\2715"; color: var(--status-danger); }

/* Read by screen readers, not shown. */
.login-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.login-link {
    display: block;
    margin-top: 16px;
    font-size: 13px;
    text-align: center;
    color: var(--pop-muted, rgba(0, 0, 0, 0.45));
}

/* Validation summary renders an empty <div> when there are no errors — keep it hidden. */
.login-alert:empty,
.login-alert.validation-summary-valid {
    display: none;
}

.login-alert {
    margin-bottom: 16px;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.login-alert ul {
    margin: 0;
    padding-left: 18px;
}

.login-alert--error {
    color: #a8071a;
    background: #fff1f0;
    border: 1px solid #ffccc7;
}

.login-alert--info {
    color: #0958d9;
    background: #e6f4ff;
    border: 1px solid #91caff;
}

.login-footer {
    flex: 0 0 auto;
    padding: 16px;
    font-size: 12px;
    text-align: center;
    color: var(--footer-text, rgba(255, 255, 255, 0.80));
}
