/* Form Validation Micro-interactions */

/* Base form states */
.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--white);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
    transform: translateY(-1px);
}

/* Validation states */
.form-group.valid .form-input {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.form-group.invalid .form-input {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    animation: shake 0.5s ease-in-out;
}

.form-group.warning .form-input {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

/* Validation icons */
.validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.form-group.valid .validation-icon.success {
    opacity: 1;
    color: #10b981;
    animation: bounceIn 0.4s ease;
}

.form-group.invalid .validation-icon.error {
    opacity: 1;
    color: #ef4444;
    animation: bounceIn 0.4s ease;
}

.form-group.warning .validation-icon.warning {
    opacity: 1;
    color: #f59e0b;
    animation: bounceIn 0.4s ease;
}

/* Validation messages */
.validation-message {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.form-group.valid .validation-message.success,
.form-group.invalid .validation-message.error,
.form-group.warning .validation-message.warning {
    opacity: 1;
    transform: translateY(0);
}

.validation-message.success {
    color: #10b981;
}

.validation-message.error {
    color: #ef4444;
}

.validation-message.warning {
    color: #f59e0b;
}

/* Progress indicator for password strength */
.password-strength {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-group.has-password-focus .password-strength {
    opacity: 1;
}

.password-strength-bar {
    height: 100%;
    background: var(--primary-orange);
    width: 0%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

.password-strength.weak .password-strength-bar {
    width: 25%;
    background: #ef4444;
}

.password-strength.fair .password-strength-bar {
    width: 50%;
    background: #f59e0b;
}

.password-strength.good .password-strength-bar {
    width: 75%;
    background: #10b981;
}

.password-strength.strong .password-strength-bar {
    width: 100%;
    background: #059669;
}

/* Character counter */
.char-counter {
    position: absolute;
    right: 12px;
    bottom: -24px;
    font-size: 0.75rem;
    color: var(--text-light);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-group:focus-within .char-counter,
.form-group.has-content .char-counter {
    opacity: 1;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.error {
    color: #ef4444;
}

/* Floating labels */
.floating-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1rem;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    padding: 0 4px;
    z-index: 10;
}

.form-group:focus-within .floating-label,
.form-group.has-content .floating-label {
    top: -8px;
    font-size: 0.75rem;
    color: var(--primary-orange);
    transform: translateY(-50%);
    font-weight: 500;
    padding: 0 8px;
}

.form-group.valid .floating-label {
    color: #10b981;
}

.form-group.invalid .floating-label {
    color: #ef4444;
}

/* Submit button states */
.submit-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.submit-btn.loading {
    color: transparent;
    pointer-events: none;
}

.submit-btn.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.submit-btn.success {
    background: #10b981 !important;
    transform: scale(1.05);
}

.submit-btn.success::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2rem;
    animation: checkmark 0.4s ease;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.3);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes checkmark {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Real-time validation feedback */
.form-field-wrapper {
    position: relative;
    margin-bottom: 2rem;
}

.form-field-wrapper.focused {
    z-index: 10;
}

.form-field-wrapper.focused .form-input {
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.15);
}

/* Email validation specific */
.email-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 150px;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.form-group.show-suggestions .email-suggestions {
    opacity: 1;
    transform: translateY(0);
}

.email-suggestion {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.email-suggestion:hover {
    background: rgba(255, 107, 53, 0.05);
    color: var(--primary-orange);
}

/* Phone number formatting */
.phone-input {
    position: relative;
}

.country-code {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1rem;
    pointer-events: none;
}

.phone-input .form-input {
    padding-left: 60px;
}

/* Dark mode adjustments */
[data-theme="dark"] .form-input {
    background: var(--card-bg);
    color: var(--text-light);
    border-color: #374151;
}

[data-theme="dark"] .form-input:focus {
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
}

[data-theme="dark"] .floating-label {
    background: var(--card-bg);
}

[data-theme="dark"] .form-input {
    background: var(--card-bg);
}

/* Ensure floating label background matches form background */
.form-group:focus-within .floating-label,
.form-group.has-content .floating-label {
    background: var(--white);
    border-radius: 4px;
}

[data-theme="dark"] .form-group:focus-within .floating-label,
[data-theme="dark"] .form-group.has-content .floating-label {
    background: var(--card-bg);
    border-radius: 4px;
}

[data-theme="dark"] .email-suggestions {
    background: var(--card-bg);
    border-color: #374151;
}

[data-theme="dark"] .email-suggestion:hover {
    background: rgba(255, 107, 53, 0.1);
}

[data-theme="dark"] .form-group.valid .form-input {
    background: rgba(16, 185, 129, 0.1);
}

[data-theme="dark"] .form-group.invalid .form-input {
    background: rgba(239, 68, 68, 0.1);
}

[data-theme="dark"] .form-group.warning .form-input {
    background: rgba(245, 158, 11, 0.1);
}

/* Accessible focus indicators */
.form-input:focus-visible {
    outline: 2px solid var(--primary-orange);
    outline-offset: 2px;
}

/* Newsletter form specific styles */
.newsletter-field {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.newsletter-field .form-input {
    padding-right: 40px;
}

.newsletter-field .validation-icon {
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.newsletter-field .validation-message {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    text-align: left;
}

.newsletter-success {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    border-radius: 8px;
    color: #10b981;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.newsletter-success i {
    font-size: 1rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .newsletter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .newsletter-field {
        max-width: none;
        margin-bottom: 1rem;
    }
    
    .newsletter-form button {
        width: 100%;
    }
}

/* Verification Modal Styles */
.verification-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.verification-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.verification-modal.active .verification-modal-overlay {
    opacity: 1;
}

.verification-modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    position: relative;
}

.verification-modal.active .verification-modal-content {
    transform: translateY(0);
    opacity: 1;
}

.verification-header {
    text-align: center;
    margin-bottom: 2rem;
}

.verification-header h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
    font-size: 1.5rem;
}

.verification-header p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

.verification-challenge {
    margin-bottom: 2rem;
}

.captcha-container {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    background: rgba(255, 107, 53, 0.02);
}

.captcha-challenge {
    margin-bottom: 1rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.3s ease;
}

.captcha-challenge.wrong-answer {
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    animation: shake 0.5s ease;
}

.math-challenge {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.math-expression {
    font-family: 'Courier New', monospace;
    background: var(--white);
    padding: 1rem 2rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.text-challenge {
    text-align: center;
}

.text-challenge p {
    margin: 0 0 0.5rem 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

.scrambled-word {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-orange);
    letter-spacing: 3px;
    font-family: 'Courier New', monospace;
}

.pattern-challenge {
    text-align: center;
}

.pattern-challenge p {
    margin: 0 0 0.5rem 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

.sequence {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    font-family: 'Courier New', monospace;
}

.color-challenge {
    text-align: center;
}

.color-challenge p {
    margin: 0 0 1rem 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 180px;
    margin: 0 auto;
}

.color-box {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.color-box:hover {
    transform: scale(1.05);
    border-color: var(--text-dark);
}

.color-box.selected {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.3);
}

.captcha-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.captcha-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--white);
}

.captcha-input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.btn-refresh {
    padding: 0.75rem;
    background: var(--light-grey);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-light);
}

.btn-refresh:hover {
    background: var(--border-color);
    color: var(--text-dark);
}

.wrong-message {
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
    text-align: center;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.verification-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-cancel,
.btn-verify {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 0.95rem;
}

.btn-cancel {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--light-grey);
}

.btn-verify {
    background: var(--primary-orange);
    color: white;
}

.btn-verify:hover:not(:disabled) {
    background: #e55a2b;
    transform: translateY(-1px);
}

.btn-verify:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Success Popup */
.form-success-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-success-popup.active {
    opacity: 1;
}

.success-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.form-success-popup.active .success-content {
    transform: translateY(0);
}

.success-content i {
    font-size: 3rem;
    color: #10b981;
    margin-bottom: 1rem;
}

.success-content h3 {
    margin: 0 0 1rem 0;
    color: var(--text-dark);
}

.success-content p {
    margin: 0 0 1.5rem 0;
    color: var(--text-light);
}

/* Error Popup */
.form-error-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-error-popup.active {
    opacity: 1;
}

.error-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.form-error-popup.active .error-content {
    transform: translateY(0);
}

.error-content i {
    font-size: 3rem;
    color: #dc2626;
    margin-bottom: 1rem;
}

.error-content h3 {
    margin: 0 0 1rem 0;
    color: var(--text-dark);
}

.error-content p {
    margin: 0 0 1.5rem 0;
    color: var(--text-light);
}

.bot-detection-error {
    animation: slideInError 0.3s ease-out;
}

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

/* Dark mode adjustments for verification modal */
[data-theme="dark"] .verification-modal-content,
[data-theme="dark"] .success-content,
[data-theme="dark"] .error-content {
    background: var(--card-bg);
}

[data-theme="dark"] .verification-header h3,
[data-theme="dark"] .success-content h3,
[data-theme="dark"] .error-content h3 {
    color: var(--text-light);
}

[data-theme="dark"] .captcha-container {
    background: rgba(255, 107, 53, 0.05);
    border-color: #374151;
}

[data-theme="dark"] .math-expression {
    background: var(--card-bg);
    border-color: #374151;
}

[data-theme="dark"] .math-challenge,
[data-theme="dark"] .sequence {
    color: var(--text-light);
}

[data-theme="dark"] .captcha-input {
    background: var(--card-bg);
    border-color: #374151;
    color: var(--text-light);
}

[data-theme="dark"] .btn-refresh {
    background: #374151;
    border-color: #4b5563;
}

[data-theme="dark"] .btn-refresh:hover {
    background: #4b5563;
}

[data-theme="dark"] .btn-cancel {
    color: var(--text-light);
    border-color: #374151;
}

[data-theme="dark"] .btn-cancel:hover {
    background: #374151;
}

/* Smooth transitions for all validation states */
.form-input,
.validation-icon,
.validation-message,
.human-check {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}