/* Formularios (jQuery Validate) de la Web y de la Suite: mismo archivo en los dos repos (ver AGENTS.md, "Forms"). */

/* Validación: globo de diálogo debajo del campo, igual que en la app (ion-input errorText en global.scss).
   div.error lo crea jQuery Validate (dore.script.js lo coloca después del campo visible); .field-validation-error
   es el mensaje del servidor (asp-validation-for). Reemplaza el tooltip flotante de Dore, que tapaba las etiquetas. */
:root {
    --field-error-bg: #fdecea;
    --field-error-border: rgba(196, 43, 28, 0.28);
    --field-error-text: #b3261e;
    --field-error-shadow: rgba(179, 38, 30, 0.14);
}

body.theme-dark {
    --field-error-bg: #3b1f1d;
    --field-error-border: rgba(255, 138, 128, 0.35);
    --field-error-text: #ffb4ab;
    --field-error-shadow: rgba(0, 0, 0, 0.35);
}

body div.error,
body .field-validation-error:not(:empty) {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    z-index: 1;
    display: table;
    width: auto !important;
    max-width: 100%;
    box-sizing: border-box;
    margin: 10px 0 4px;
    padding: 6px 12px 6px 30px;
    border: 1px solid var(--field-error-border);
    border-radius: 10px;
    background-color: var(--field-error-bg);
    /* Ícono de alerta (círculo con "!"). */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23d93025'/%3E%3Crect x='11' y='6' width='2' height='8' rx='1' fill='white'/%3E%3Ccircle cx='12' cy='17.3' r='1.3' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 9px center;
    background-size: 15px 15px;
    color: var(--field-error-text) !important;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    box-shadow: 0 4px 12px var(--field-error-shadow);
    animation: field-error-bubble-in 0.18s ease-out;
}

/* Piquito del globo apuntando hacia el campo (reemplaza los triángulos de Dore). */
body div.error::before,
body .field-validation-error:not(:empty)::before {
    content: '';
    position: absolute;
    top: -6px;
    bottom: auto;
    left: 16px;
    right: auto;
    margin: 0;
    width: 10px;
    height: 10px;
    background: var(--field-error-bg);
    border: 0;
    border-left: 1px solid var(--field-error-border);
    border-top: 1px solid var(--field-error-border);
    transform: rotate(45deg);
}

body div.error::after,
body .field-validation-error:not(:empty)::after {
    content: none;
}

/* Campos obligatorios: * en su etiqueta, como en la app. Por el atributo required, por data-val-required (ASP.NET,
   p. ej. fechas no nulas) o, si la regla vive en JS (alta de expedientes), por la clase de markRequiredLabels (forms.js). */
.form-group:has(> :is(input, select, textarea)[required]) > label::after,
.form-group:has(> :is(input:not([type=hidden], [type=checkbox], [type=radio]), select, textarea)[data-val-required]) > label::after,
label.required-label::after {
    content: " *";
    color: var(--field-error-text);
    font-weight: 700;
}

@keyframes field-error-bubble-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
