/**
 * Frontend Auth Forms Styles
 * Styles for login, registration, and comment forms on the frontend
 * 
 * @since 3.7.0
 */

// Username availability checker
.username-field-wrapper {
    position: relative;
    
    input.checking {
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="2"><circle cx="12" cy="12" r="10"/></svg>');
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
        animation: spin 1s linear infinite;
    }
    
    input.available {
        border-color: #4caf50 !important;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg>');
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
    }
    
    input.taken {
        border-color: #f44336 !important;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23f44336" stroke-width="3"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>');
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

// Password strength meter
.password-strength-meter {
    margin-top: 8px;
    
    .strength-bar {
        height: 4px;
        background: #e0e0e0;
        border-radius: 2px;
        overflow: hidden;
        margin-bottom: 5px;
        
        .strength-bar-fill {
            height: 100%;
            width: 0;
            transition: width 0.3s ease, background-color 0.3s ease;
            
            &.weak {
                width: 33%;
                background: linear-gradient(90deg, #f44336, #e53935);
            }
            
            &.medium {
                width: 66%;
                background: linear-gradient(90deg, #ff9800, #fb8c00);
            }
            
            &.strong {
                width: 100%;
                background: linear-gradient(90deg, #4caf50, #43a047);
            }
        }
    }
    
    .strength-text {
        font-size: 12px;
        font-weight: 600;
        
        &.weak {
            color: #f44336;
        }
        
        &.medium {
            color: #ff9800;
        }
        
        &.strong {
            color: #4caf50;
        }
    }
}

// Password field wrapper for toggle button
.password-field-wrapper {
    position: relative;
    
    input[type="password"],
    input[type="text"] {
        padding-right: 45px;
    }
    
    .password-toggle {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        cursor: pointer;
        padding: 5px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #666;
        transition: color 0.2s ease;
        
        &:hover {
            color: #333;
        }
        
        &.visible {
            color: #4a6cf7;
        }
        
        svg {
            width: 20px;
            height: 20px;
        }
    }
}

// Password match validation
input.password-match {
    border-color: #4caf50 !important;
}

input.password-mismatch {
    border-color: #f44336 !important;
}

// Field validation states
input.field-valid,
textarea.field-valid,
select.field-valid {
    border-color: #4caf50 !important;
}

input.field-error-state,
textarea.field-error-state,
select.field-error-state {
    border-color: #f44336 !important;
}

.field-error {
    display: block;
    color: #f44336;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

// Auth links styling
.simpleform-auth-links {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    
    a {
        color: #4a6cf7;
        text-decoration: none;
        transition: color 0.2s ease;
        
        &:hover {
            color: #3c57d0;
            text-decoration: underline;
        }
    }
}

// Comment custom fields display
.comment-custom-fields {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 3px solid #4a6cf7;
    border-radius: 4px;
    
    .comment-custom-field {
        margin-bottom: 6px;
        font-size: 14px;
        line-height: 1.6;
        
        &:last-child {
            margin-bottom: 0;
        }
        
        strong {
            color: #333;
            font-weight: 600;
            margin-right: 5px;
        }
    }
}

// Loading state for auth forms
.simple_form.auth-form-loading {
    opacity: 0.6;
    pointer-events: none;
    
    &::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 40px;
        height: 40px;
        border: 4px solid #f3f4f6;
        border-top-color: #4a6cf7;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
}

// Remember me toggle
.simple-form-checkbox-toggle {
    .switch-label {
        display: flex;
        align-items: center;
        cursor: pointer;
        user-select: none;
        font-size: 14px;
        
        .switch-input {
            position: relative;
            width: 44px;
            height: 24px;
            margin-right: 10px;
            appearance: none;
            background: #ccc;
            border-radius: 12px;
            outline: none;
            cursor: pointer;
            transition: background 0.3s ease;
            
            &::after {
                content: '';
                position: absolute;
                width: 20px;
                height: 20px;
                background: white;
                border-radius: 50%;
                top: 2px;
                left: 2px;
                transition: transform 0.3s ease;
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            }
            
            &:checked {
                background: #4a6cf7;
                
                &::after {
                    transform: translateX(20px);
                }
            }
        }
    }
}

// Email validation indicator
.email-field-wrapper {
    position: relative;
    
    input.email-valid {
        border-color: #4caf50 !important;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg>');
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
    }
    
    input.email-invalid {
        border-color: #f44336 !important;
    }
}

// Form submission states
.simple_form {
    position: relative;
    
    &.submitting {
        .simple-form-submit-btn {
            opacity: 0.7;
            cursor: not-allowed;
            pointer-events: none;
            
            &::after {
                content: '';
                display: inline-block;
                width: 14px;
                height: 14px;
                margin-left: 8px;
                border: 2px solid currentColor;
                border-top-color: transparent;
                border-radius: 50%;
                animation: spin 0.6s linear infinite;
                vertical-align: middle;
            }
        }
    }
    
    &.submission-success {
        .simple-form-submit-btn {
            background-color: #4caf50 !important;
            border-color: #4caf50 !important;
        }
    }
    
    &.submission-error {
        .simple-form-submit-btn {
            background-color: #f44336 !important;
            border-color: #f44336 !important;
        }
    }
}

// Success/Error messages
.simpleform-message {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    animation: slideDown 0.3s ease;
    
    &.success {
        background-color: #e8f5e9;
        color: #2e7d32;
        border-left: 4px solid #4caf50;
    }
    
    &.error {
        background-color: #ffebee;
        color: #c62828;
        border-left: 4px solid #f44336;
    }
    
    &.info {
        background-color: #e3f2fd;
        color: #1565c0;
        border-left: 4px solid #2196f3;
    }
    
    &.warning {
        background-color: #fff3e0;
        color: #e65100;
        border-left: 4px solid #ff9800;
    }
    
    &::before {
        content: '';
        display: inline-block;
        width: 20px;
        height: 20px;
        margin-right: 10px;
        flex-shrink: 0;
    }
    
    &.success::before {
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%232e7d32" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg>');
    }
    
    &.error::before {
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23c62828" stroke-width="3"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>');
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

// Real-time validation feedback
.field-validating {
    position: relative;
    
    &::after {
        content: '';
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 16px;
        height: 16px;
        border: 2px solid #999;
        border-top-color: transparent;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }
}

// Tooltip for validation hints
.validation-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
    
    &::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 20px;
        border: 5px solid transparent;
        border-top-color: #333;
    }
    
    &.show {
        opacity: 1;
    }
}

// Password requirements list
.password-requirements {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
    
    ul {
        margin: 0;
        padding-left: 20px;
        list-style: none;
        
        li {
            position: relative;
            padding-left: 20px;
            margin-bottom: 4px;
            color: #666;
            
            &::before {
                content: '○';
                position: absolute;
                left: 0;
                color: #999;
            }
            
            &.met {
                color: #4caf50;
                
                &::before {
                    content: '✓';
                    color: #4caf50;
                    font-weight: bold;
                }
            }
            
            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}

// Focus states enhancement
.simple_form {
    input:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: #4a6cf7;
        box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    
    input.field-error-state:focus,
    textarea.field-error-state:focus {
        border-color: #f44336;
        box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
    }
    
    input.field-valid:focus,
    textarea.field-valid:focus {
        border-color: #4caf50;
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
    }
}

// Disabled state
.simple_form {
    input:disabled,
    textarea:disabled,
    select:disabled,
    button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        background-color: #f5f5f5;
    }
}

// Character counter for text fields
.char-counter {
    display: block;
    text-align: right;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    
    &.warning {
        color: #ff9800;
    }
    
    &.error {
        color: #f44336;
    }
}

// Autocomplete styling
.simple_form {
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 30px white inset !important;
        -webkit-text-fill-color: #333 !important;
    }
}

// Accessibility improvements
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

// ARIA live region for screen readers
.validation-announcer {
    @extend .sr-only;
}

// Responsive design
@media (max-width: 768px) {
    .password-field-wrapper {
        .password-toggle {
            right: 8px;
        }
    }
    
    .comment-custom-fields {
        padding: 10px;
        font-size: 13px;
    }
    
    .simpleform-message {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .password-requirements {
        font-size: 11px;
    }
    
    .validation-tooltip {
        font-size: 11px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .password-strength-meter {
        .strength-text {
            font-size: 11px;
        }
    }
    
    .simple-form-checkbox-toggle {
        .switch-label {
            font-size: 13px;
            
            .switch-input {
                width: 40px;
                height: 22px;
                
                &::after {
                    width: 18px;
                    height: 18px;
                }
                
                &:checked::after {
                    transform: translateX(18px);
                }
            }
        }
    }
}
