/**
 * Enhanced Forms CSS
 * Styling for improved contact form user experience
 * Stone OnePoint Solutions Website
 */

/* Form Container Enhancements */
.contact-form {
    position: relative;
    transition: all 0.3s ease;
}

.contact-form.form-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Form Messages */
.form-message {
    margin-bottom: 20px;
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    animation: slideInDown 0.3s ease-out;
}

.form-message i {
    font-size: 20px;
    flex-shrink: 0;
}

.form-message.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid #28a745;
}

.form-message.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Form Field Validation States */
.form-control {
    transition: all 0.3s ease;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid #e9ecef;
}

.form-control:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
    outline: none;
}

.form-control.is-valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.94-.94 2.94 2.94L8.5 6.4l.94.94L6.5 10.27z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4m0-2.4L5.8 7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

/* Validation Feedback */
.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875em;
    margin-top: 0.5rem;
    font-weight: 500;
    animation: fadeInUp 0.3s ease-out;
}

.valid-feedback {
    display: block;
    color: #28a745;
    font-size: 0.875em;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Character Counter */
.character-counter {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.character-counter.text-muted {
    color: #6c757d !important;
}

.character-counter.text-warning {
    color: #ffc107 !important;
}

.character-counter.text-danger {
    color: #dc3545 !important;
}

/* Progress Indicator */
.form-progress {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #dee2e6;
    animation: slideInDown 0.3s ease-out;
}

.form-progress .progress {
    height: 8px;
    margin-bottom: 12px;
    border-radius: 4px;
    background-color: #e9ecef;
    overflow: hidden;
}

.form-progress .progress-bar {
    background: linear-gradient(90deg, #4a90e2 0%, #357abd 100%);
    transition: width 0.3s ease;
}

.form-progress small {
    color: #6c757d;
    font-weight: 500;
}

/* Submit Button Enhancements */
.default-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border-radius: 25px;
    padding: 12px 30px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.default-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

.default-btn .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    margin-right: 8px;
}

/* Loading Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.form-loading .form-control {
    animation: pulse 2s infinite;
}

/* Form Field Focus Effects */
.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-control:focus + .form-label,
.form-control:not(:placeholder-shown) + .form-label {
    transform: translateY(-1.5rem) scale(0.85);
    color: #4a90e2;
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .form-message {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .form-control {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .default-btn {
        width: 100%;
        padding: 14px 20px;
    }
}

/* Animations */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Error state animation */
.form-control.shake {
    animation: shake 0.5s ease-in-out;
}

/* Success checkmark animation */
@keyframes checkmark {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-checkmark {
    animation: checkmark 0.6s ease-in-out;
}

/* Form field icons */
.form-group.has-icon {
    position: relative;
}

.form-group.has-icon .form-control {
    padding-left: 45px;
}

.form-group.has-icon textarea.form-control {
    padding-left: 45px;
    padding-top: 15px;
}

.form-group.has-icon .form-icon {
    position: absolute;
    left: 15px;
    top: 15px;
    color: #6c757d;
    font-size: 18px;
    z-index: 2;
    transition: color 0.3s ease;
}

.form-group.has-icon .form-control:focus + .form-icon,
.form-group.has-icon .form-control.is-valid + .form-icon {
    color: #4a90e2;
}

.form-group.has-icon .form-control.is-invalid + .form-icon {
    color: #dc3545;
}

/* Accessibility Enhancements */
.form-control:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }
    
    .form-control:focus {
        border-color: #000;
        box-shadow: 0 0 0 3px #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .form-control,
    .default-btn,
    .form-message {
        transition: none;
        animation: none;
    }
}