/**
 * WKDM Dealer Registration - Login Page Styling
 * Based on WKDM Redesign Design System
 *
 * Font: Qanelas (already loaded by theme)
 * Accent: var(--wkdm-accent) — set dynamically via PHP (Orange or Blue)
 * Dark: #292D35
 * Medium Grey: #585E6D
 * Light Grey: #C2CDE3
 * Error: #F56356
 */

/* =============================================
   Body & Background
   ============================================= */
body.login {
    background-color: #292D35 !important;
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* =============================================
   Login Container
   ============================================= */
#login {
    width: 420px;
    max-width: 90vw;
    padding: 0;
    margin: 0;
}

/* =============================================
   Logo Area
   ============================================= */
#login h1 {
    margin-bottom: 0;
    padding-bottom: 0;
    text-align: center;
}

#login h1 a {
    margin-bottom: 24px;
}

/* =============================================
   Login Form Box
   ============================================= */
.login form {
    background: #ffffff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 48px 40px 36px;
    margin-top: 0;
}

/* =============================================
   Fieldset-Legend Input Pattern (Enhanced by JS)
   ============================================= */
.wkdm-login-field-group {
    margin-bottom: 28px;
}

.wkdm-login-fieldset {
    border: 1px solid #C2CDE3;
    border-radius: 6px;
    padding: 2px 0 0 0;
    margin: 0;
    position: relative;
    transition: border-color 0.2s ease;
}

.wkdm-login-fieldset:focus-within {
    border-color: var(--wkdm-accent);
}

.wkdm-login-fieldset legend {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #585E6D;
    padding: 0 5px;
    margin: 0 0 0 15px;
    line-height: 1;
    float: none;
    width: auto;
}

.wkdm-login-fieldset input[type="text"],
.wkdm-login-fieldset input[type="password"],
.wkdm-login-fieldset input[type="email"] {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 40px;
    width: 100%;
    padding: 0 20px;
    font-size: 16px;
    color: #292D35;
    background: transparent;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
    outline: none;
    margin: 0;
    box-sizing: border-box;
}

.wkdm-login-fieldset input::placeholder {
    color: #C2CDE3;
}

/* =============================================
   Password Field with Eye Icon
   ============================================= */
.wkdm-login-fieldset .wp-pwd {
    position: relative;
    display: flex;
    align-items: center;
}

.wkdm-login-fieldset .wp-pwd input[type="password"],
.wkdm-login-fieldset .wp-pwd input[type="text"] {
    flex: 1;
    padding-right: 50px;
}

.wkdm-login-fieldset .wp-hide-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px;
    margin: 0;
    cursor: pointer;
    color: #C2CDE3;
    height: auto;
    min-height: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wkdm-login-fieldset .wp-hide-pw:hover,
.wkdm-login-fieldset .wp-hide-pw:focus {
    color: var(--wkdm-accent);
    background: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.wkdm-login-fieldset .wp-hide-pw .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
}

/* =============================================
   Fallback: Non-enhanced Input Styling
   (Before JS runs or if JS fails)
   ============================================= */
body.login:not(.wkdm-login-enhanced) .login form input[type="text"],
body.login:not(.wkdm-login-enhanced) .login form input[type="password"],
body.login:not(.wkdm-login-enhanced) .login form input[type="email"] {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 40px;
    width: 100%;
    padding: 0 20px;
    font-size: 16px;
    color: #292D35;
    background: #ffffff;
    border: 1px solid #C2CDE3;
    border-radius: 6px;
    box-shadow: none;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    margin-bottom: 4px;
    margin-top: 6px;
}

body.login:not(.wkdm-login-enhanced) .login form input:focus {
    border-color: var(--wkdm-accent);
    box-shadow: none;
}

body.login:not(.wkdm-login-enhanced) .login label {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #585E6D;
}

/* =============================================
   reCAPTCHA Widget on Login Form
   ============================================= */
.wkdm-dr-login-recaptcha {
    margin: 16px 0 8px;
    display: flex;
    justify-content: center;
}

/* Scale down reCAPTCHA on small screens */
@media (max-width: 380px) {
    .wkdm-dr-login-recaptcha {
        transform: scale(0.85);
        transform-origin: center;
    }
}

/* =============================================
   Disabled Submit Button (waiting for reCAPTCHA)
   ============================================= */
#wp-submit.wkdm-btn-disabled,
#wp-submit:disabled {
    background: #C2CDE3 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

#wp-submit.wkdm-btn-disabled:hover,
#wp-submit:disabled:hover {
    background: #C2CDE3 !important;
}

/* =============================================
   Actions Row (Remember Me + Login Button)
   ============================================= */
.wkdm-login-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    gap: 16px;
}

/* "Remember me" checkbox area */
.wkdm-login-actions-row .forgetmenot {
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 auto;
    white-space: nowrap;
}

.wkdm-login-actions-row .forgetmenot label,
.login .forgetmenot label {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px !important;
    color: #585E6D;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle;
}

.login input[type="checkbox"] {
    border: 1px solid #C2CDE3 !important;
    border-radius: 4px !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle;
    flex-shrink: 0;
}

.login input[type="checkbox"]:checked {
    background-color: var(--wkdm-accent);
    border-color: var(--wkdm-accent);
}

.login input[type="checkbox"]:checked::before {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='white' d='M14.83 4.89l1.34 1.34-9.29 9.28-4.05-4.05 1.34-1.34 2.71 2.71z'/%3E%3C/svg%3E");
    margin: -1px 0 0 -1px;
    width: 16px;
    height: 16px;
}

.login input[type="checkbox"]:focus {
    border-color: var(--wkdm-accent);
    box-shadow: none;
    outline: none;
}

/* Login Submit Button (smaller, auto-width) */
.wkdm-login-actions-row .submit {
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
}

#wp-submit {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--wkdm-accent) !important;
    border: none !important;
    border-radius: 50px !important;
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    height: 40px !important;
    line-height: 40px !important;
    padding: 0 24px !important;
    width: auto !important;
    text-shadow: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 0;
}

#wp-submit:hover,
#wp-submit:focus {
    background: var(--wkdm-accent-hover) !important;
    box-shadow: none !important;
    outline: none !important;
}

#wp-submit:active {
    background: var(--wkdm-accent-active) !important;
}

/* Fallback: When JS hasn't created the actions row yet */
body.login:not(.wkdm-login-enhanced) .login .forgetmenot {
    margin-top: 8px;
}

body.login:not(.wkdm-login-enhanced) .login .forgetmenot label {
    font-size: 13px;
    color: #585E6D;
}

body.login:not(.wkdm-login-enhanced) .login .submit {
    padding-top: 8px;
}

body.login:not(.wkdm-login-enhanced) #wp-submit {
    width: 100% !important;
    height: 50px !important;
    line-height: 50px !important;
    font-size: 16px !important;
    margin-top: 16px;
}

/* =============================================
   Navigation Links Below Form
   (Dealer Account Button + Lost Password)
   ============================================= */
#login #nav {
    text-align: center;
    padding: 20px 28px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    font-size: 0; /* hide "|" separator text nodes */
    /*background: rgba(255, 255, 255, 0.06);*/
    background-color: white;
    border-radius: 8px;
    margin-bottom: 30px;
}

/* Dealer Account Button (accent color, pill shape) */
#login #nav a[href*="dealer-application"] {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: inline-block;
    background: var(--wkdm-accent);
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    padding: 10px 28px;
    border-radius: 50px;
    text-align: center;
    transition: background-color 0.2s ease;
    box-sizing: border-box;
}

#login #nav a[href*="dealer-application"]:hover {
    background: var(--wkdm-accent-hover);
    color: #ffffff !important;
    text-decoration: none;
}

/* Lost Password Link */
#login #nav a[href*="lostpassword"] {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #585E6D;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

#login #nav a[href*="lostpassword"]:hover {
    color: var(--wkdm-accent);
    text-decoration: underline;
}

/* Back to blog link */
#login #backtoblog {
    text-align: center;
    padding: 0;
    margin-top: 12px;
}

#login #backtoblog a {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #585E6D;
    font-size: 13px;
    font-weight: 400;
    text-decoration: none;
}

#login #backtoblog a:hover {
    color: var(--wkdm-accent);
}

/* =============================================
   Error/Message Boxes
   ============================================= */
.login .message,
.login .success {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border-left: 4px solid #28CF99;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #292D35;
}

.login #login_error {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border-left: 4px solid #F56356;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #292D35;
}

.login #login_error a {
    color: var(--wkdm-accent);
    font-weight: 600;
}

/* =============================================
   Password Strength Meter
   ============================================= */
.login .pw-weak {
    margin-top: 8px;
}

/* =============================================
   Privacy Policy & Language Switcher
   ============================================= */
.login .privacy-policy-page-link {
    margin-top: 16px;
    text-align: center;
}

.login .privacy-policy-page-link a {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #585E6D;
    font-size: 12px;
    font-weight: 400;
}

.login .privacy-policy-page-link a:hover {
    color: var(--wkdm-accent);
}

.login .language-switcher {
    margin-top: 16px;
}

.login .language-switcher select {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border: 1px solid #C2CDE3;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    color: #292D35;
}

.login .language-switcher .button {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #585E6D;
    border: none;
    border-radius: 50px;
    color: #ffffff;
    font-size: 14px;
    padding: 8px 16px;
    cursor: pointer;
}

.login .language-switcher .button:hover {
    background: #292D35;
}

/* =============================================
   2FA Plugin Compatibility
   Ensure common 2FA fields are styled properly
   ============================================= */
.login form .input-token,
.login form input[name="two-factor-code"],
.login form input[name="authcode"],
.login form .2fa-input {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 40px;
    width: 100%;
    padding: 0 20px;
    font-size: 16px;
    color: #292D35;
    border: 1px solid #C2CDE3;
    border-radius: 6px;
    box-shadow: none;
    outline: none;
    box-sizing: border-box;
}

.login form .input-token:focus,
.login form input[name="two-factor-code"]:focus,
.login form input[name="authcode"]:focus {
    border-color: var(--wkdm-accent);
}

/* =============================================
   Password Reset Page (?action=rp / resetpass)
   Hide nav links + style Generate Password button
   ============================================= */
body.login-action-rp #login #nav,
body.login-action-resetpass #login #nav,
body.login-action-rp #login #backtoblog,
body.login-action-resetpass #login #backtoblog {
    display: none;
}

/* "Generate Password" button → grey, rounded, small, centered */
.login .wp-generate-pw {
    font-family: 'Qanelas', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #585E6D !important;
    border: none !important;
    border-radius: 50px !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    height: 36px !important;
    line-height: 36px !important;
    padding: 0 20px !important;
    width: auto !important;
    text-shadow: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: block !important;
    margin: 0 auto 16px !important;
}

.login .wp-generate-pw:hover,
.login .wp-generate-pw:focus {
    background: #292D35 !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Reset form: center the submit button row */
body.login-action-rp .submit,
body.login-action-resetpass .submit {
    text-align: center;
}

body.login-action-rp #wp-submit,
body.login-action-resetpass #wp-submit {
    margin: 0 auto;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    #login {
        width: 100%;
        max-width: 90vw;
    }

    .login form {
        padding: 32px 24px 28px;
    }

    .wkdm-login-fieldset input[type="text"],
    .wkdm-login-fieldset input[type="password"],
    .wkdm-login-fieldset input[type="email"] {
        height: 38px;
        font-size: 16px;
    }

    .wkdm-login-actions-row {
        flex-direction: column;
        gap: 12px;
    }

    .wkdm-login-actions-row .forgetmenot {
        order: 2;
    }

    .wkdm-login-actions-row .submit {
        order: 1;
        width: 100%;
    }

    #wp-submit {
        width: 100% !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 15px !important;
    }
}
