/**
 * Biogen PAC – Custom Login Page Styles
 * #loginform IS the card — flexbox layout with gap for spacing.
 * Matches ARDX PAC design language.
 */

/* === Background === */
body.biogen-login {
    background:
        linear-gradient(135deg, rgba(1, 23, 44, 0.85), rgba(28, 117, 188, 0.80)),
        url('../assets/login-bg.jpg') center / cover no-repeat !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Hide WP chrome === */
body.biogen-login #login h1 a,
body.biogen-login #backtoblog,
body.biogen-login #nav,
body.biogen-login .language-switcher {
    display: none !important;
}

/* === Hide miniOrange stray elements (OR divider, extra HRs) === */
body.biogen-login #loginform hr,
body.biogen-login #loginform .mo_saml_login {
    display: none !important;
}

/* === Center the login wrapper === */
body.biogen-login #login {
    width: 100%;
    max-width: 400px;
    padding: 0 1rem;
    margin: 0 auto;
}

body.biogen-login #login h1 {
    margin: 0;
    padding: 0;
}

/* Hide form until JS restructures it — prevents flash of unstyled content */
body.biogen-login #loginform:not(.biogen-ready) {
    opacity: 0;
}

/* === loginform IS the card === */
body.biogen-login #loginform {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #F7F7F8;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -2px rgba(0, 0, 0, 0.1);
    padding: 2.25rem 2.5rem;
    text-align: center;
    margin: 0;
    border: none;
}

/* All direct children — reset margins, let gap handle spacing */
body.biogen-login #loginform > * {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

/* === Header group (logo + heading + subtitle) === */
.biogen-login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

/* === Logo === */
.biogen-login-logo {
    display: block;
    max-width: 160px;
    height: auto;
    margin: 0 auto 0.75rem;
}

/* === Heading === */
.biogen-login-heading {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #53575A;
    margin: 0;
}

/* === Subtitle === */
.biogen-login-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    color: rgba(83, 87, 90, 0.7);
    margin: 0;
    line-height: 1.4;
    max-width: 260px;
    text-wrap: balance;
}

/* === Section transitions (fade instead of display:none) === */
#biogen-okta-section,
#biogen-credentials-section {
    transition: opacity 0.2s ease, max-height 0.2s ease;
}

.biogen-hidden {
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* === Okta section === */
#biogen-okta-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* === Okta / SAML button ===
   #mo_saml_login_sso_button is a div.button.button-primary with heavy inline
   styles. We strip inline styles via JS and replace the class with .biogen-okta-btn.
   Target both the class AND the ID as a fallback. */
.biogen-okta-btn,
#mo_saml_login_sso_button,
#biogen-okta-section input[type="submit"],
#biogen-okta-section button:not(.biogen-toggle-link) {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    background: #1C75BC !important;
    color: #fff !important;
    border: none !important;
    border-radius: 9999px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    text-align: center !important;
    transition: opacity 0.2s !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    box-shadow: none !important;
    min-height: 48px !important;
    height: auto !important;
    line-height: 1.4 !important;
}

/* The mo_saml_button wrapper — kill its fixed height */
#mo_saml_button {
    height: auto !important;
    margin: 5px 0 !important;
    padding: 0 !important;
}

.biogen-okta-btn:hover,
#mo_saml_login_sso_button:hover,
#biogen-okta-section input[type="submit"]:hover,
#biogen-okta-section button:not(.biogen-toggle-link):hover {
    opacity: 0.9;
}

.biogen-okta-btn:focus-visible,
#mo_saml_login_sso_button:focus-visible,
#biogen-okta-section input[type="submit"]:focus-visible,
#biogen-okta-section button:not(.biogen-toggle-link):focus-visible {
    outline: 2px solid #1C75BC;
    outline-offset: 2px;
}

/* === Toggle links ===
   These are <button> elements, so WP's .button base styles can leak in.
   Use !important to fully reset. */
.biogen-toggle-link {
    display: inline-block !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: rgba(83, 87, 90, 0.6) !important;
    font-size: 0.875rem !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    min-height: 0 !important;
    height: auto !important;
    line-height: 1.4 !important;
    width: auto !important;
    border-radius: 0 !important;
    align-self: center !important;
}

.biogen-toggle-link:hover {
    color: #53575A !important;
    background: none !important;
}

.biogen-toggle-link:focus-visible {
    outline: 2px solid #1C75BC;
    outline-offset: 2px;
}

/* === Credentials section === */
#biogen-credentials-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

/* Reset margins on all children inside credentials — gap handles spacing */
#biogen-credentials-section > * {
    margin: 0;
}

#biogen-credentials-section label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #53575A;
    margin: 0 0 0.25rem;
}

#biogen-credentials-section input[type="text"],
#biogen-credentials-section input[type="password"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    margin: 0;
    box-sizing: border-box;
    background: rgba(217, 217, 217, 0.25);
    color: #53575A;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#biogen-credentials-section input[type="text"]:focus,
#biogen-credentials-section input[type="password"]:focus {
    border-color: #53575A;
    outline: none;
    box-shadow: 0 0 0 2px rgba(83, 87, 90, 0.2);
}

#biogen-credentials-section input[type="text"]:focus-visible,
#biogen-credentials-section input[type="password"]:focus-visible {
    border-color: #1C75BC;
    box-shadow: 0 0 0 2px rgba(28, 117, 188, 0.3);
}

/* Remember Me — full width row */
#biogen-credentials-section .forgetmenot {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

#biogen-credentials-section .forgetmenot label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 400;
    color: rgba(83, 87, 90, 0.7);
    cursor: pointer;
}

/* Submit button */
#biogen-credentials-section .submit,
body.biogen-login #loginform > .submit {
    margin: 0;
    padding: 0;
}

#biogen-credentials-section input[type="submit"],
#biogen-credentials-section .button-primary,
body.biogen-login #loginform > .submit input[type="submit"],
body.biogen-login #loginform > .submit .button-primary {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1C75BC !important;
    color: #fff !important;
    border: none !important;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s;
    box-sizing: border-box;
    margin: 0;
    min-height: 48px;
    line-height: 1.4;
}

#biogen-credentials-section input[type="submit"]:hover,
#biogen-credentials-section .button-primary:hover,
body.biogen-login #loginform > .submit input[type="submit"]:hover,
body.biogen-login #loginform > .submit .button-primary:hover {
    opacity: 0.9;
}

#biogen-credentials-section input[type="submit"]:focus-visible,
#biogen-credentials-section .button-primary:focus-visible,
body.biogen-login #loginform > .submit input[type="submit"]:focus-visible,
body.biogen-login #loginform > .submit .button-primary:focus-visible {
    outline: 2px solid #1C75BC;
    outline-offset: 2px;
}

/* === WP password wrapper — tame the toggle icon === */
#biogen-credentials-section .wp-pwd {
    position: relative;
}

#biogen-credentials-section .wp-pwd .button.wp-hide-pw {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    box-shadow: none;
    color: #999;
    padding: 0.25rem;
    border-radius: 0 !important;
    width: auto !important;
    min-height: 0 !important;
}

/* === Error / info messages === */
body.biogen-login #login_error,
body.biogen-login .message {
    max-width: 400px;
    margin: 0 auto 0.75rem;
    border-radius: 0.375rem;
    border-left: 4px solid;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

body.biogen-login #login_error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #991b1b;
}

body.biogen-login .message {
    background: #eff6ff;
    border-color: #1C75BC;
    color: #1e40af;
}

/* === Responsive === */
@media (max-width: 480px) {
    body.biogen-login #loginform {
        padding: 1.5rem 1.25rem;
    }

    body.biogen-login #login {
        padding: 0 0.75rem;
    }
}
