/* Prevent FOUC (Flash of Unstyled Content) on my-account page */
/* Hide forms when replacement is active (class added via PHP) */
body.woocommerce-account:not(.woocommerce-logged-in).wspf-form-replacement-active #customer_login {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Show forms after replacement is complete */
body.woocommerce-account:not(.woocommerce-logged-in).wspf-form-replacement-active.wspf-forms-ready #customer_login {
    opacity: 1;
}

/* Резерв высоты только пока JS подгружает форму (после wspf-forms-ready — без пустоты) */
body.wspf-form-replacement-active:not(.wspf-forms-ready) .wespefy-form-placeholder {
    min-height: 400px;
}

body.wspf-forms-ready .wespefy-form-placeholder {
    display: none;
    min-height: 0;
}

.wespefy-form-placeholder + form.woocommerce-form-login,
.wespefy-form-placeholder + form.woocommerce-form-register,
.wespefy-form-placeholder + form.login,
.wespefy-form-placeholder + form.register {
    display: none;
}

.login #login {
    width: 60vw;
    max-width: 400px;
    margin-top: 5vh;
}

.login form#language-switcher label {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.login #language-switcher input[type="submit"],
.login #language-switcher button[type="submit"],
.login form#language-switcher input[type="submit"],
.login form#language-switcher button[type="submit"] {
    display: none !important;
}

.wp-login-logo {
    display: block !important;
}

#wp-auth-check {
    max-height: 100% !important;
    height: auto !important;
}

#wp-auth-check-wrap {
    max-height: 100% !important;
    height: auto !important;
}

#wp-auth-check-wrap .wspf-wespe-auth-form-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    margin: 0;
    box-sizing: border-box;
}

#wp-auth-check-wrap .wspf-wespe-auth-form-wrapper .wspf-wespe-auth-form {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

#wp-auth-check-wrap .wspf-wespe-auth-form-wrapper h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#wp-auth-check-wrap .wspf-form-field {
    margin-bottom: 1rem;
}

#wp-auth-check-wrap .wspf-code-inputs-wrapper {
    gap: 6px;
    margin: 0.75rem 0;
}

#wp-auth-check-wrap .wspf-code-digit {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}

#wp-auth-check-wrap .wspf-wespe-auth-form .button {
    padding: 0.6rem;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

/* Base styles for form wrapper (all contexts) */
.wspf-wespe-auth-form-wrapper {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 32px 40px;
    max-width: 400px;
    margin: 2rem auto;
    box-sizing: border-box;
}

.wspf-wespe-auth-form-wrapper .wspf-wespe-auth-form {
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
}

/* Login page specific overrides */
.login .wspf-wespe-auth-form-wrapper {
    /* Inherits base styles */
}

.login .wspf-wespe-auth-form-wrapper .wspf-wespe-auth-form {
    max-width: 100%;
}

body.login .wspf-wespe-auth-form:not(.wspf-wespe-auth-form-wrapper .wspf-wespe-auth-form) {
    max-width: 400px;
    margin: 2rem auto;
    padding: 0;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.wspf-wespe-auth-form-wrapper.wspf-hidden {
    display: none !important;
}

.wspf-wespe-auth-form.wspf-hidden {
    display: none !important;
}

.wspf-wespe-auth-form h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #333;
}

.login .wspf-wespe-auth-form form {
    margin: 24px 0;
    padding: 0;
    font-weight: 400;
    overflow: hidden;
    background: #fff;
    border: none;
    box-shadow: none;
}

.login .wspf-wespe-auth-form #nav {
    margin: 24px 0 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.wspf-form-field {
    margin-bottom: 1.5rem;
}

.wspf-form-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.wspf-form-field input[type="tel"],
.wspf-form-field input[type="text"],
.wspf-form-field input[type="email"],
.wspf-form-field input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    margin: 0;
}

.wspf-form-field input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.wspf-form-field .wspf-field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6e6e6e;
}

.wspf-wespe-auth-form .button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.wspf-wespe-auth-form .button-primary {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.wspf-wespe-auth-form .button-primary:hover {
    background: #005a87;
    border-color: #005a87;
}

.wspf-back-button {
    background: #f0f0f0;
    border-color: #ddd;
    color: #333;
}

.wspf-back-button:hover {
    background: #e0e0e0;
}

.wspf-code-fields,
.wspf-registration-fields,
.wspf-password-fields {
    display: none;
}

.wspf-code-fields:not(.wspf-hidden),
.wspf-registration-fields:not(.wspf-hidden),
.wspf-password-fields:not(.wspf-hidden) {
    display: block;
}

.wspf-code-inputs-wrapper {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 1rem 0;
    padding: 3px;
}

.wspf-code-digit {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.wspf-code-digit:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
    transform: scale(1.05);
}

.wspf-code-digit:invalid {
    border-color: #d63638;
}

.wspf-code-digit.wspf-code-error {
    border-color: #d63638;
    background-color: #fff5f5;
    animation: wspf-shake 0.5s ease-in-out;
}

.wspf-code-digit.wspf-code-valid {
    border-color: #00a32a;
    background-color: #f0f9f4;
}

.wspf-code-digit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wspf-code-inputs-wrapper.wspf-shake {
    animation: wspf-shake 0.5s ease-in-out;
}

.wspf-form-messages {
    margin-top: 1rem;
}

.wspf-form-messages .wspf-notice {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.wspf-form-messages .wspf-notice-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.wspf-form-messages .wspf-notice-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.wspf-form-messages .wspf-notice-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.wspf-alternative-login {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e0e0e0;
}

.wspf-alternative-login-title {
    font-size: 14px;
    color: #50575e;
    margin-bottom: 16px;
    text-align: center;
}

.wspf-alternative-login-button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    color: #2271b1;
    text-decoration: none;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wspf-alternative-login-button:hover {
    background: #f6f7f7;
    border-color: #2271b1;
}

.wspf-alternative-login-button:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.login .wspf-wespe-auth-form-wrapper .wspf-standard-form {
    max-width: 100%;
}

.wspf-wespe-auth-form-wrapper .wspf-standard-form {
    background: #fff;
    border-radius: 8px;
}

body .wspf-wespe-auth-form-wrapper .wspf-standard-form form.register {
    border: none;
    padding: 0;
    margin: 0 auto;
    text-align: left;
    border-radius: 0;
}

body .woocommerce .wspf-wespe-auth-form-wrapper .wspf-standard-form form.login {
    border: none;
    padding: 0;
    margin: 0 auto;
    text-align: left;
    border-radius: 0;
}

.wspf-standard-form.wspf-hidden {
    display: none;
}

.login .wspf-standard-form form {
    margin: 24px 0;
    font-weight: 400;
    overflow: hidden;
    background: #fff;
    border: none;
    box-shadow: none;
}

.wspf-standard-form form label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e1e1e;
}

.wspf-standard-form form input[type="text"],
.wspf-standard-form form input[type="password"],
.wspf-standard-form form input[type="email"] {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #fff;
    color: #2c3338;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.wspf-standard-form form input[type="text"]:focus,
.wspf-standard-form form input[type="password"]:focus,
.wspf-standard-form form input[type="email"]:focus {
    border-color: #2271b1;
    outline: 2px solid #2271b1;
    outline-offset: 0;
}

.wspf-standard-form form .login-remember {
    margin: 16px 0;
}

.wspf-standard-form form .login-remember label {
    display: inline;
    font-weight: normal;
    font-size: 13px;
    margin-left: 8px;
}

.wspf-standard-form form input[type="checkbox"] {
    margin-right: 4px;
}

.wspf-standard-form form input[type="submit"],
.wspf-standard-form form button[type="submit"] {
    width: 100%;
    padding: 12px 20px;
    background: #2271b1;
    border: 1px solid #2271b1;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 16px;
}

.wspf-standard-form form input[type="submit"]:hover,
.wspf-standard-form form button[type="submit"]:hover {
    background: #135e96;
    border-color: #135e96;
}

.wspf-standard-form form input[type="submit"]:focus,
.wspf-standard-form form button[type="submit"]:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.wspf-standard-form-nav {
    text-align: center;
    margin-top: 1rem;
    margin-bottom: 0;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.wspf-standard-form form .wspf-standard-form-nav {
    margin-top: 1rem;
    margin-bottom: 0;
}

.wspf-standard-form-nav a {
    color: #2271b1;
    text-decoration: none;
}

.wspf-standard-form-nav a:hover {
    color: #135e96;
    text-decoration: underline;
}

.login .wspf-standard-form-nav,
.login form .wspf-standard-form-nav {
    margin-top: 1.5rem;
}

#registerform.wspf-hidden {
    display: none !important;
}

body.wspf-checkout-phone-only .woocommerce-checkout .woocommerce-billing-fields,
.woocommerce-checkout:has(.wspf-checkout-phone-form-wrapper) .woocommerce-billing-fields {
    display: none !important;
}

body.wspf-checkout-phone-only .woocommerce-checkout .woocommerce-billing-fields.wspf-billing-fields-visible,
.woocommerce-checkout:has(.wspf-checkout-phone-form-wrapper) .woocommerce-billing-fields.wspf-billing-fields-visible {
    display: block !important;
}

.woocommerce-checkout .form-row.wspf-checkout-field-hidden,
.woocommerce-checkout .form-row[data-wspf-hidden="true"] {
    display: none !important;
}

.wspf-checkout-phone-form-wrapper {
    margin-bottom: 2rem;
    display: block !important;
}

.woocommerce-checkout .wspf-checkout-phone-form-wrapper {
    display: block !important;
    visibility: visible !important;
}

.wspf-checkout-user-data {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.wspf-checkout-user-data h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.wspf-checkout-user-data .wspf-user-data-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.wspf-checkout-user-data .wspf-user-data-row:last-child {
    border-bottom: none;
}

.wspf-checkout-user-data .wspf-user-data-label {
    font-weight: 600;
    color: #666;
    margin-right: 1rem;
}

.wspf-checkout-user-data .wspf-user-data-value {
    color: #333;
    text-align: right;
}

.wspf-checkout-user-data .wspf-edit-billing-btn {
    width: 100%;
    margin-top: 1rem;
}

.woocommerce-checkout .form-row.wspf-checking {
    position: relative;
}

.woocommerce-checkout .form-row.wspf-checking::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.wspf-form-step {
    animation: fadeIn 0.3s ease-in;
}

.wspf-hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wspf-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

@media (max-width: 480px) {
    .wspf-wespe-auth-form {
        margin: 1rem;
        padding: 1.5rem;
    }
}
