/**
 * Tadawul Form Validation Styles
 * Error messages and validation feedback
 */

/* Form field with error */
.tadawul-field-error {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
}

.tadawul-field-error:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Error message text */
.tadawul-error-message {
    color: #dc3545;
    font-size: 13px;
    font-weight: 500;
    margin-top: 5px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    display: block;
    animation: slideInError 0.3s ease-out;
}

/* Success message */
.tadawul-success-message {
    color: #155724;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 16px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 15px;
    display: block;
    animation: slideInSuccess 0.3s ease-out;
}

/* Form error message */
.tadawul-form-error-message {
    color: #721c24;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 16px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 15px;
    display: block;
    animation: slideInError 0.3s ease-out;
}

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

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

/* Valid field indicator */
.tadawul-field-valid {
    border-color: #28a745 !important;
}

.tadawul-field-valid:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* Validation icon */
.tadawul-validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
}

.tadawul-validation-icon.error {
    color: #dc3545;
}

.tadawul-validation-icon.success {
    color: #28a745;
}

/* Loading state */
.tadawul-form-loading {
    opacity: 0.6;
    pointer-events: none;
}

.tadawul-form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Input wrapper for validation */
.tadawul-input-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.tadawul-input-wrapper input,
.tadawul-input-wrapper select,
.tadawul-input-wrapper textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.tadawul-input-wrapper input:focus,
.tadawul-input-wrapper select:focus,
.tadawul-input-wrapper textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Required field indicator */
.tadawul-required::after {
    content: ' *';
    color: #dc3545;
    font-weight: bold;
}

/* Validation summary */
.tadawul-validation-summary {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 15px;
    color: #721c24;
}

.tadawul-validation-summary h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
}

.tadawul-validation-summary ul {
    margin: 0;
    padding-left: 20px;
}

.tadawul-validation-summary li {
    margin-bottom: 4px;
    font-size: 14px;
}

/* Tooltip for field hints */
.tadawul-field-hint {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    display: block;
}

/* Disabled state */
.tadawul-form-disabled input,
.tadawul-form-disabled select,
.tadawul-form-disabled textarea,
.tadawul-form-disabled button {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Submit button states */
button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button[type="submit"]:disabled:hover {
    background-color: inherit;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .tadawul-error-message,
    .tadawul-success-message,
    .tadawul-form-error-message {
        font-size: 12px;
        padding: 10px 12px;
    }

    .tadawul-validation-summary {
        font-size: 13px;
        padding: 10px 12px;
    }

    .tadawul-validation-summary h4 {
        font-size: 14px;
    }
}
