/* =====================================================================
   Form validation states — used by media/js/form-validation.js
   Shared by the public contact form and the admin / login forms.
   ===================================================================== */

.os-req {
    color: #e11d48;
    margin-left: 2px;
}

/* Field states */
input.is-invalid,
select.is-invalid,
textarea.is-invalid,
.has-error .select2-container--default .select2-selection--single,
.has-error .file-input-label {
    border-color: #e11d48 !important;
    background-color: #fff7f8 !important;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, .12) !important;
}

input.is-valid,
textarea.is-valid,
.has-success .select2-container--default .select2-selection--single {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .1) !important;
}

/* status icon inside text inputs */
input.is-invalid:not([type="file"]):not([type="password"]),
input.is-valid:not([type="file"]):not([type="password"]) {
    padding-right: 42px !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 18px 18px !important;
}

input.is-invalid:not([type="file"]):not([type="password"]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e11d48' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7v6M12 16.5v.5'/%3E%3C/svg%3E") !important;
}

input.is-valid:not([type="file"]):not([type="password"]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") !important;
}

/* Error message under a field */
.os-field-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0 !important;
    max-height: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #be123c;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height .3s ease, opacity .3s ease, transform .3s ease, margin .3s ease;
}

.os-field-error:not(:empty) {
    max-height: 80px;
    margin-top: 7px !important;
    opacity: 1;
    transform: none;
}

.os-field-error:not(:empty)::before {
    content: "";
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23be123c'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2zm0-4h-2V7h2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.has-error > label { color: #be123c !important; }

/* Character counter */
.os-char-counter {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    color: #6b7c90;
    font-variant-numeric: tabular-nums;
}

.os-char-counter.is-near { color: #d97706; }

/* Form-level status line (above the submit button) */
.os-form-status {
    margin: 0 0 14px !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.os-form-status:empty { display: none; }
.os-form-status.is-error { color: #be123c; }
.os-form-status.is-info { color: #1466a8; }

/* Gentle shake when a submit is blocked */
.os-shake { animation: os-shake .45s ease; }

@keyframes os-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
    .os-shake { animation: none; }
}

/* Contact form: keep the textarea and counter tidy */
.message-area textarea { min-height: 130px; }
.message-area { margin-bottom: 18px !important; }

/* busy submit button (admin forms) */
.os-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: .85;
}

.os-btn-loading::before {
    content: "";
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 8px;
    vertical-align: -2px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    animation: os-btn-spin .8s linear infinite;
}

@keyframes os-btn-spin { to { transform: rotate(360deg); } }
