/* Form feedback styles */
.success-message {
    color: var(--black);
    background-color: var(--green);
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: 300;
    margin-top: 20px;
    animation: fadeIn 0.5s ease-in-out;
}

.error-message {
    color: white;
    background-color: rgba(255, 0, 0, 0.7);
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: 300;
    margin-top: 20px;
    animation: fadeIn 0.5s ease-in-out;
}

.input-error-message {
    color: #D32F2F; /* Match input border color */
    font-size: 0.85rem;
    margin-top: 5px;
    margin-bottom: 10px;
    display: block;
    animation: fadeIn 0.3s ease-in-out;
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 400;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Style for form when submitting */
.form-group.submitting input {
    background-color: rgba(255, 255, 255, 0.5);
}

.submit-btn:disabled,
.submit-btn[aria-disabled="true"] {
    background-color: #999;
    cursor: not-allowed;
}

/* Loading Spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    vertical-align: text-bottom;
    margin-right: 8px;
}

/* Ensure flexbox for alignment when spinner is present */
.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Character Counter */
.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--black);
    margin-top: 4px;
    opacity: 0.7;
    font-variant-numeric: tabular-nums; /* Prevent jitter when numbers change */
}

.char-count.limit-reached {
    color: #D32F2F;
    font-weight: 500;
    opacity: 1;
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
    .shake,
    .success-message,
    .error-message,
    .input-error-message,
    .submit-btn [role="status"] {
        animation: none;
    }
}


/* Hide form elements on success */
.hidden-on-success {
    display: none !important;
}

/* Loader Polish */
.submit-btn [role="status"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
}
