/* WordPress MFA + Passkey Plugin - Clean Native Styles */

/* =================================================================
   MAIN LOGIN CONTROLS
   ================================================================= */

.wmp-login-controls {
}

.wmp-step-controls {
    margin-bottom: 16px;
}

/* Step 1 Layout */
#wmp-step-1-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* =================================================================
   STEP 1: USERNAME + CONTINUE + PASSKEY
   ================================================================= */

/* Continue Button */
.wmp-continue-submit {
    margin: 0 !important;
}

#wmp-continue-btn {
    width: 100%;
    font-size: 16px;
}

/* Login Divider - Flexbox Solution */
.wmp-login-divider {
    display: flex;
    align-items: center;
    margin: 0;
    gap: 12px;
}

.wmp-login-divider:before,
.wmp-login-divider:after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.wmp-login-divider span {
    color: #666;
    font-size: 14px;
    white-space: nowrap;
    padding: 0 4px;
}

/* Passkey Section */
.wmp-passkey-section {
    text-align: center;
}

/* WordPress standard button styling with passkey-specific enhancements */
.wmp-passkey-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
}

.wmp-passkey-btn .wmp-passkey-icon {
    font-size: 18px;
    line-height: 1;
}

.wmp-passkey-btn .wmp-passkey-text {
    font-weight: 500;
}

.wmp-passkey-icon {
    font-size: 18px;
}

.wmp-passkey-description {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.wmp-forgot-password {
    margin-top: 12px;
    margin-bottom: 0;
    text-align: center;
    font-size: 13px;
}

.wmp-forgot-password a {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.wmp-forgot-password a:hover {
    color: #0073aa;
    text-decoration: underline;
}

/* =================================================================
   STEP 2 & 3: HEADERS AND BACK LINKS
   ================================================================= */

.wmp-step-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.wmp-current-user {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
}

.wmp-mfa-notice {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #0073aa;
    font-weight: 500;
}

.wmp-back-link {
    background: none;
    border: none;
    color: #0073aa;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    float: right;
}

.wmp-back-link:hover {
    background-color: #f0f6fc;
    text-decoration: none;
}

.wmp-back-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 1px;
}

/* Clear floats */
.wmp-step-header:after {
    content: "";
    display: table;
    clear: both;
}

/* =================================================================
   HIDE PASSWORD FIELDS IN STEP 1 (Simple approach)
   ================================================================= */

/* Hide password field by default */
.user-pass-wrap,
#user_pass-hide,
label[for="user_pass"],
.wp-pwd {
    display: none;
}

/* Show password field when in step 2 */
body.wmp-step-2 .user-pass-wrap,
body.wmp-step-2 #user_pass-hide,
body.wmp-step-2 label[for="user_pass"],
body.wmp-step-2 .wp-pwd {
    display: block !important;
}

/* Hide default WordPress login elements in step 1 */
.forgetmenot,
.submit:not(.wmp-continue-submit) {
    display: none;
}

/* Show WordPress elements only in step 2 and beyond */
body.wmp-step-2 .forgetmenot,
body.wmp-step-2 .submit:not(.wmp-continue-submit),
body.wmp-step-3 .forgetmenot {
    display: block;
}

/* Step Headers */
.wmp-step-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.wmp-step-header p {
    margin: 0;
    font-size: 14px;
}

/* Back Buttons */
.wmp-back-btn {
    background: none !important;
    border: none !important;
    color: #0073aa !important;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.wmp-back-btn:hover {
    background-color: #f0f6fc !important;
    text-decoration: none;
}

.wmp-back-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 1px;
}

/* Passkey Overlay */
#wmp-passkey-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wmp-passkey-modal {
    background: white;
    border-radius: 8px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: wmpModalSlideIn 0.2s ease-out;
}

.wmp-passkey-content {
    padding: 30px;
    text-align: center;
}

.wmp-passkey-content h3 {
    color: #0073aa;
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 18px;
}

.wmp-passkey-content p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Spinner Animation */
.wmp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: wmpSpin 1s linear infinite;
    margin: 20px auto;
}

@keyframes wmpSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes wmpModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Login Messages */
.wmp-login-message {
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    animation: wmpSlideDown 0.3s ease-out;
}

.wmp-login-message.wmp-error {
    background-color: #d63638;
    color: white;
    border-left: 4px solid #b32d2e;
}

.wmp-login-message.wmp-success {
    background-color: #00ba37;
    color: white;
    border-left: 4px solid #00a32a;
}

.wmp-login-message.wmp-info {
    background-color: #0073aa;
    color: white;
    border-left: 4px solid #005a87;
}

@keyframes wmpSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Login Form Styling */
#loginform {
    position: relative;
}

#loginform .input {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#loginform .input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
    outline: none;
}

/* Username field with conditional UI styling */
#user_login[autocomplete*="webauthn"] {
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%230073aa"><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4z"/><path d="M10 17l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z" fill="white"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px 18px;
    padding-right: 35px;
}

/* Legacy MFA Code Styling */
#wmp-mfa-code {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px;
}

#wmp-mfa-code label {
    font-weight: 600;
    color: #856404;
}

#wmp_mfa_code {
    width: 100%;
    max-width: 200px;
    text-align: center;
    font-size: 18px;
    letter-spacing: 2px;
    font-family: monospace;
}

/* Legacy Passkey Button Styling */
#wmp-passkey-auth {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 12px;
    text-align: center;
}

/* Legacy passkey button - now uses WordPress standard classes */

/* Passkey Alternative Section */
.wmp-passkey-alternative {
    margin-top: 20px;
    text-align: center;
}

.wmp-divider {
    position: relative;
    margin: 20px 0;
    text-align: center;
}

.wmp-divider:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
}

.wmp-divider span {
    background: #fff;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
    position: relative;
}

.wmp-passkey-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.wmp-passkey-login-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.2);
}

.wmp-passkey-login-btn:active {
    transform: translateY(0);
}

.wmp-passkey-login-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.wmp-passkey-icon {
    font-size: 18px;
    line-height: 1;
}

.wmp-passkey-text {
    font-weight: 500;
}

.wmp-passkey-description {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Hide passkey option by default, show with JavaScript */
#wmp-passkey-option {
    display: none;
}

/* Enhanced Button Styling */
#wp-submit {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#wp-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.2);
}

#wp-submit:active {
    transform: translateY(0);
}

#wp-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading state for buttons */
.wmp-loading {
    position: relative;
    color: transparent !important;
}

.wmp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: wmpSpin 1s linear infinite;
}

/* Legacy Error/Success States */
.wmp-error {
    color: #d63384;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

.wmp-success {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

/* Focus improvements for accessibility */
.wmp-back-btn:focus-visible,
#wmp-cancel-passkey:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wmp-login-message {
        border: 2px solid;
    }
    
    .wmp-step-header {
        border-bottom-color: #333;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .wmp-passkey-modal {
        width: 95%;
        margin: 20px;
    }
    
    .wmp-passkey-content {
        padding: 20px;
    }
    
    .wmp-step-header {
        text-align: left;
    }
    
    .wmp-back-btn {
        position: static;
        display: block;
        text-align: left;
        margin-bottom: 8px;
    }
    
    /* Legacy mobile styles */
    #wmp-auth-options,
    #wmp-mfa-code,
    #wmp-passkey-auth {
        margin-left: -12px;
        margin-right: -12px;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }
    
    .wmp-passkey-btn {
        width: 100%;
        padding: 16px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wmp-login-step,
    .wmp-login-message,
    .wmp-passkey-modal,
    #wp-submit {
        transition: none;
        animation: none;
    }
    
    .wmp-spinner {
        animation: none;
        border-top-color: transparent;
    }
}