/* ============================================================
   FORM ERROR STATES + ANIMATIONS
   ============================================================ */

.field {
    position: relative;
}

/* ---------- Error state on field ---------- */
.field.has-error input,
.field.has-error textarea,
.field.has-error select {
    border-color: #ff4d4d !important;
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.15) !important;
    background-color: rgba(255, 77, 77, 0.04) !important;
}

.field.has-success input {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12) !important;
}

/* ---------- Inline error message ---------- */
.field-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #ff6b6b;
    line-height: 1.4;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-4px);
    transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.25s ease;
}

.field-error::before {
    content: "⚠";
    font-size: 0.85rem;
    flex-shrink: 0;
}

.field.has-error .field-error {
    max-height: 60px;
    opacity: 1;
    transform: translateY(0);
}

.field-error.visible {
    max-height: 60px;
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Shake animation ---------- */
@keyframes field-shake {

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

    15% {
        transform: translateX(-7px);
    }

    30% {
        transform: translateX(6px);
    }

    45% {
        transform: translateX(-5px);
    }

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

    75% {
        transform: translateX(-2px);
    }
}

.field.shake input,
.field.shake textarea,
.field.shake select {
    animation: field-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {

    .field.shake input,
    .field.shake textarea,
    .field.shake select {
        animation: none;
    }
}

/* ---------- Required asterisk ---------- */
.field label.required::after {
    content: " *";
    color: #ff6b6b;
    font-weight: 700;
}

/* ---------- Submit button loading ---------- */
.auth-btn,
button[type="submit"] {
    position: relative;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

button.loading {
    color: transparent !important;
    pointer-events: none;
}

button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- Form-level error banner (for non-field errors) ---------- */
.form-error-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: rgba(255, 77, 77, 0.08);
    border: 1px solid rgba(255, 77, 77, 0.3);
    border-radius: 10px;
    color: #ff8a8a;
    font-size: 0.88rem;
    line-height: 1.5;
    text-align: right;
}

.form-error-banner.visible {
    display: flex;
    animation: banner-in 0.3s ease;
}

.form-error-banner__icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff4d4d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

@keyframes banner-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

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

/**
 * Copyright (c) 2026 Sobhan Rasoulzadeh Asl (Sobhan-SRZA / Mr. Sinre)
 *
 * Licensed under the BSD 3-Clause License.
 * See the LICENSE file in the project root for license information.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */