/* Optimized Contact Form Styles */

/* Progress Bar */
.form-progress {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--color-surface, #f8f9fa);
    border-radius: 8px;
}

.progress-bar {
    height: 8px;
    background: var(--color-border, #e0e0e0);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #45a049 100%);
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease;
}

.progress-fill.complete {
    background: linear-gradient(90deg, #2196F3 0%, #1976D2 100%);
    animation: pulse 1s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--color-text-secondary, #666);
    text-align: center;
}

/* Form Messages */
.form-message {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    animation: slideDown 0.3s ease;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.form-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Field Errors */
.field-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    animation: slideDown 0.2s ease;
}

/* Input States */
.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-input:focus.error,
.form-textarea:focus.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* Character Counter */
.form-character-count {
    text-align: right;
    font-size: 0.875rem;
    color: var(--color-text-secondary, #666);
    margin-top: 0.25rem;
    transition: color 0.2s ease;
}

.form-character-count .warning {
    color: #ffa500;
    font-weight: 500;
}

.form-character-count .error {
    color: #dc3545;
    font-weight: 500;
}

/* Submit Button States */
.btn-primary.submitting {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-primary.submitting .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Improved Focus States */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary, #2196F3);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Valid Field Indicator */
.form-input:valid:not(:placeholder-shown),
.form-textarea:valid:not(:placeholder-shown) {
    border-color: #28a745;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2328a745'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* Textarea doesn't need checkmark */
.form-textarea:valid:not(:placeholder-shown) {
    background-image: none;
    padding-right: 1rem;
}

/* Loading State for Form */
.contact-form.loading {
    position: relative;
    pointer-events: none;
}

.contact-form.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Honeypot Spam Protection */
.honeypot-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .form-progress {
        padding: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .progress-bar {
        height: 6px;
    }

    .form-message {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Larger touch targets on mobile */
    .form-input,
    .form-textarea,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Stack form groups on mobile */
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .form-progress {
        background: rgba(255, 255, 255, 0.05);
    }

    .progress-bar {
        background: rgba(255, 255, 255, 0.1);
    }

    .form-message.success {
        background: rgba(40, 167, 69, 0.1);
        color: #5cb85c;
        border-color: rgba(40, 167, 69, 0.3);
    }

    .form-message.error {
        background: rgba(220, 53, 69, 0.1);
        color: #f5707a;
        border-color: rgba(220, 53, 69, 0.3);
    }

    .form-message.info {
        background: rgba(33, 150, 243, 0.1);
        color: #5bc0de;
        border-color: rgba(33, 150, 243, 0.3);
    }
}

/* Accessibility Improvements */
.skip-link:focus {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 1000;
    text-decoration: none;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .form-input,
    .form-textarea,
    .form-select {
        border-width: 2px;
    }

    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        outline: 3px solid;
        outline-offset: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}