/**
 * Validation Error Display Styles
 * External CSS to avoid Content Security Policy violations
 */

/* Global error container */
.validation-errors-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    pointer-events: none;
}

.validation-errors-container > * {
    pointer-events: auto;
    margin-bottom: 10px;
}

/* Field validation errors */
.validation-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 0.25rem;
    border-left: 3px solid #dc3545;
    animation: slideIn 0.3s ease-out;
}

.validation-error--error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.validation-error--warning {
    background-color: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.validation-error--info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.validation-error--critical {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid #8b0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.2);
}

.validation-error__content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.validation-error__icon {
    flex-shrink: 0;
    font-weight: bold;
}

.validation-error__text {
    flex: 1;
}

.validation-error__close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.validation-error__close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

/* Tooltip errors */
.validation-error--tooltip {
    position: fixed;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    max-width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10001;
}

.validation-error--tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 16px;
    border: 6px solid transparent;
    border-bottom-color: #333;
}

.validation-error--tooltip-below::before {
    bottom: auto;
    top: 100%;
    border-bottom-color: transparent;
    border-top-color: #333;
}

/* Global validation errors */
.global-validation-error {
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: slideInRight 0.3s ease-out;
}

.global-validation-error--error {
    border-left: 4px solid #dc3545;
}

.global-validation-error--warning {
    border-left: 4px solid #ffc107;
}

.global-validation-error--info {
    border-left: 4px solid #17a2b8;
}

.global-validation-error--critical {
    border-left: 4px solid #8b0000;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.3);
}

.global-validation-error__header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.global-validation-error__icon {
    font-size: 18px;
    flex-shrink: 0;
}

.global-validation-error__text {
    flex: 1;
    font-weight: 500;
}

/* Validation summary */
.validation-summary {
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #dc3545;
    overflow: hidden;
    animation: slideInRight 0.3s ease-out;
}

.validation-summary__header {
    padding: 16px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #dee2e6;
}

.validation-summary__title {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #721c24;
}

.validation-summary__toggle {
    background: none;
    border: 1px solid #dee2e6;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.validation-summary__list {
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.validation-summary__item {
    border-bottom: 1px solid #dee2e6;
}

.validation-summary__item:last-child {
    border-bottom: none;
}

.validation-summary__link {
    display: block;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.validation-summary__link:hover {
    background-color: #f8f9fa;
}

/* Inline container */
.validation-inline-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .validation-errors-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .validation-error--tooltip {
        max-width: calc(100vw - 20px);
    }
}

/* Input validation states */
.validating {
    border-color: #ffc107 !important;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.25);
    opacity: 0.8;
}

.valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
}

.invalid,
.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
    animation: shake 0.3s ease-in-out;
}

/* Ensure relative positioning for pseudo-elements */
input.validating,
input.valid,
input.invalid,
input.error {
    position: relative;
    padding-right: 30px;
}

/* Success checkmark */
.valid::after {
    content: '✓';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #28a745;
    font-weight: bold;
    font-size: 14px;
}

/* Error X mark */
.invalid::after,
.error::after {
    content: '✗';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #dc3545;
    font-weight: bold;
    font-size: 14px;
}

/* Validating spinner */
.validating::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid #ffc107;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Form validation summary */
.form-validation-summary {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.form-validation-summary h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.form-validation-summary ul {
    margin: 0;
    padding-left: 1.5rem;
}

.form-validation-summary li {
    margin-bottom: 0.25rem;
}

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

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