/**
 * UX Validation — Styles
 * Unified error display, animations, and state indicators
 */

/* ========================================
   Error Container
   ======================================== */

.ux-val-error-container {
    margin-top: 4px;
    padding: 0;
    animation: ux-val-slide-in 0.25s ease-out;
}

/* Same look as the theme's shared field-error component (classic_child
   custom.css, "Form Error Styling"), so every storefront form reads alike. */
.ux-val-error-message {
    font-size: var(--fz-14, 14px);
    line-height: 1.4;
    color: var(--cError, #c4320a);
    margin: 2px 0;
    padding: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.ux-val-error-message::before {
    content: '';
    display: inline-block;
    flex: none;
    width: 14px;
    /* The icon box must equal the first text line so the glyph centres on it.
       1.4em matches the message's line-height. */
    height: 1.4em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23c4320a'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm0 10.5a.75.75 0 110-1.5.75.75 0 010 1.5zM8.75 4.75v4a.75.75 0 01-1.5 0v-4a.75.75 0 011.5 0z'/%3E%3C/svg%3E");
    background-size: 14px 14px;
    background-position: 0 center;
    background-repeat: no-repeat;
}

/* ========================================
   Form-Level Errors
   ======================================== */

.ux-val-form-errors {
    background: #fff5f5;
    border: 1px solid var(--cError, #c4320a);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    animation: ux-val-slide-in 0.25s ease-out;
}


/* ========================================
   Input State Styling
   ======================================== */

/* Error state */
input.ux-val-error,
textarea.ux-val-error,
select.ux-val-error {
    border-color: var(--cError, #c4320a) !important;
    box-shadow: 0 0 0 2px rgba(196, 50, 10, 0.15) !important;
}

/* The theme's checkbox hides the native input and draws .frn-checkbox__checkmark. */
.frn-checkbox__control.ux-val-error ~ .frn-checkbox__checkmark {
    border-color: var(--cError, #c4320a);
}

input.ux-val-error:focus,
textarea.ux-val-error:focus,
select.ux-val-error:focus {
    border-color: var(--cError, #c4320a) !important;
    box-shadow: 0 0 0 3px rgba(196, 50, 10, 0.2) !important;
    outline: none;
}

/* Valid state (subtle green) */
input.ux-val-valid,
textarea.ux-val-valid,
select.ux-val-valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.1) !important;
}

input.ux-val-valid:focus,
textarea.ux-val-valid:focus,
select.ux-val-valid:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15) !important;
    outline: none;
}

/* ========================================
   Theme-Specific Overrides (furni theme)
   ======================================== */

/* frn-input wrappers */
.frn-input .ux-val-error-container {
    padding: 0 0 0 0;
    margin-top: 6px;
}

.frn-login__field .ux-val-error-container {
    margin-top: 4px;
}

/* Promo code area */
.promo-code .ux-val-error-container {
    margin-top: 8px;
}

/* Checkout specific */
.checkout-step .ux-val-error-container {
    margin-top: 4px;
    margin-bottom: 8px;
}

/* Newsletter block */
.block_newsletter .ux-val-error-container,
.email_subscription .ux-val-error-container {
    margin-top: 6px;
}

/* Product comments modal */
#product-comment-modal .ux-val-error-container {
    margin-top: 4px;
}

/* Password reset */
.frn-remind-password .ux-val-error-container {
    margin-top: 6px;
}

/* ========================================
   Character Counter (optional enhancement)
   ======================================== */

.ux-val-char-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 2px;
}

.ux-val-char-counter.ux-val-char-over {
    color: var(--cError, #c4320a);
    font-weight: 600;
}

/* ========================================
   Animations
   ======================================== */

@keyframes ux-val-slide-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ux-val-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* Apply shake to inputs with errors on submit */
.ux-val-error-shake {
    animation: ux-val-shake 0.3s ease-in-out;
}

/* ========================================
   Screen Reader Only
   ======================================== */

.ux-val-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .ux-val-form-errors {
        padding: 8px 10px;
        margin-bottom: 12px;
    }
}