/**
 * Form Validation Component Styles
 *
 * Einheitliche Fehlerstyles fuer alle Formularkomponenten.
 * Funktioniert mit: text-input, textarea, searchable-select, multiselect,
 * checkbox, radio, native select, datepicker.
 *
 * WICHTIG: Fehler werden immer nur durch einen roten unteren Strich angezeigt,
 * niemals durch einen vollstaendigen roten Rahmen.
 *
 * @version 1.1.0
 */

/* ========================================
   Base Error Message Styles
   ======================================== */
.field-validation-error {
    color: var(--error-color, #c84646);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-validation-error::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c84646'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* ========================================
   Global Error State - Only Bottom Border
   Applies to ALL inputs with validation error
   ======================================== */
input.has-validation-error:not([type="checkbox"]):not([type="radio"]),
textarea.has-validation-error,
select.has-validation-error,
.form-input.has-validation-error,
.text-input-field.has-validation-error,
.textarea-field.has-validation-error {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

input.has-validation-error:not([type="checkbox"]):not([type="radio"]):focus,
textarea.has-validation-error:focus,
select.has-validation-error:focus,
.form-input.has-validation-error:focus,
.text-input-field.has-validation-error:focus,
.textarea-field.has-validation-error:focus {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
    outline: none !important;
    box-shadow: none !important;
}

/* ========================================
   Text Input Component Error State
   ======================================== */
.text-input-component.has-error .text-input-field,
.text-input-component.has-error .textarea-field {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

.text-input-component.has-error .text-input-field:focus,
.text-input-component.has-error .textarea-field:focus {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Searchable Select Error State
   ======================================== */
.searchable-select.has-error .searchable-select-display {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

.searchable-select.has-error .searchable-select-display:focus,
.searchable-select.has-error.open .searchable-select-display {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Multiselect Error State
   ======================================== */
.multiselect.has-error .multiselect-display {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

.multiselect.has-error .multiselect-display:focus,
.multiselect.has-error.open .multiselect-display {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Checkbox Error State
   ======================================== */
.checkbox-wrapper.has-error input[type="checkbox"] + label::before,
.submit-checkbox-wrapper.has-error input[type="checkbox"] + label::before,
.checkbox-label.has-error input[type="checkbox"] + label::before,
.form-group.has-error input[type="checkbox"] + label::before,
input[type="checkbox"].has-validation-error + label::before {
    border-color: var(--error-color, #c84646);
}

.checkbox-wrapper.has-error,
.submit-checkbox-wrapper.has-error,
.checkbox-label.has-error,
.checkbox-group.has-error {
    padding: 8px;
    border-radius: 8px;
    background-color: rgba(200, 70, 70, 0.05);
    border: 1px solid var(--error-color, #c84646);
}

/* ========================================
   Radio Button Error State
   ======================================== */
.radio-wrapper.has-error input[type="radio"] + label::before,
.form-group.has-error input[type="radio"] + label::before,
.radio-group.has-error input[type="radio"] + label::before,
input[type="radio"].has-validation-error + label::before {
    border-color: var(--error-color, #c84646);
}

.radio-wrapper.has-error,
.radio-group.has-error {
    padding: 8px;
    margin: -8px;
    border-radius: 4px;
    background-color: rgba(200, 70, 70, 0.05);
}

/* ========================================
   Native Select Error State
   ======================================== */
select.has-validation-error,
.select-wrapper.has-error select {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

select.has-validation-error:focus,
.select-wrapper.has-error select:focus {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Datepicker Error State
   ======================================== */
.datepicker-wrapper.has-error input,
.datepicker-wrapper.has-error .datepicker-input {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

.datepicker-wrapper.has-error input:focus,
.datepicker-wrapper.has-error .datepicker-input:focus {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Generic Form Group Error State
   ======================================== */
.form-group.has-error > label,
.form-group.has-error > .form-label {
    color: var(--error-color, #c84646);
}

.form-group.has-error input:not([type="checkbox"]):not([type="radio"]),
.form-group.has-error textarea,
.form-group.has-error select {
    border: none !important;
    border-bottom: 1px solid var(--error-color, #c84646) !important;
}

.form-group.has-error input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group.has-error textarea:focus,
.form-group.has-error select:focus {
    border: none !important;
    border-bottom: 2px solid var(--error-color, #c84646) !important;
    margin-bottom: -1px;
}

/* ========================================
   Animation for Error Appearance
   ======================================== */
.field-validation-error {
    animation: fadeIn 0.2s ease-out;
}

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

/* ========================================
   NO outline/box-shadow on error fields
   This overrides any browser defaults
   ======================================== */
.has-validation-error:focus,
.has-validation-error:focus-visible,
.has-error input:focus,
.has-error input:focus-visible,
.has-error textarea:focus,
.has-error textarea:focus-visible,
.has-error select:focus,
.has-error select:focus-visible,
.has-error .searchable-select-display:focus,
.has-error .searchable-select-display:focus-visible,
.has-error .multiselect-display:focus,
.has-error .multiselect-display:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}
