/* Form Styles
 * Styles for form states, errors, loading, and transitions
 */

/* Form error states */
form input.error,
form textarea.error,
form select.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.field-error.hidden {
    display: none;
}

/* Form message (success/error) */
.form-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-message.hidden {
    display: none;
}

.form-message.text-green-600 {
    color: #16a34a;
    background-color: #dcfce7;
}

.form-message.text-red-600 {
    color: #dc2626;
    background-color: #fee2e2;
}

/* Loading spinner */
.button-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.button-loading.hidden {
    display: none;
}

.button-loading .animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Redirect overlay */
#redirect-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

#redirect-overlay > div {
    background-color: white;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

#redirect-overlay .animate-spin {
    animation: spin 1s linear infinite;
}

/* ─── Form submission overlay ─── */

.form-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: formOverlayFadeIn 0.2s ease forwards;
}

/* Dark mode */
.dark .form-overlay {
    background: rgba(15, 23, 42, 0.88);
    color: #f1f5f9;
}

/* Glassmorphism theme (modern) — overlay inherits the translucent look */
.bg-white\/10 > .form-overlay,
[class*="backdrop-blur"] > .form-overlay {
    background: rgba(0, 0, 0, 0.70);
    color: #f1f5f9;
}

.form-overlay-content {
    text-align: center;
    padding: 1.5rem;
}

/* Spinner */
.form-overlay-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

/* Icon (checkmark / X) */
.form-overlay-icon {
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 auto 0.5rem;
}

.form-overlay-icon-success {
    color: #16a34a;
}

.form-overlay-icon-error {
    color: #dc2626;
}

.dark .form-overlay-icon-success {
    color: #4ade80;
}

.dark .form-overlay-icon-error {
    color: #f87171;
}

.form-overlay-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.form-overlay-text {
    font-size: 0.9375rem;
    opacity: 0.85;
}

/* Success tint */
.form-overlay-success {
    background: rgba(220, 252, 231, 0.92);
}

.dark .form-overlay-success {
    background: rgba(20, 83, 45, 0.88);
}

/* Error tint */
.form-overlay-error {
    background: rgba(254, 226, 226, 0.92);
}

.dark .form-overlay-error {
    background: rgba(127, 29, 29, 0.88);
}

/* Glassmorphism success/error */
.bg-white\/10 > .form-overlay-success,
[class*="backdrop-blur"] > .form-overlay-success {
    background: rgba(20, 83, 45, 0.80);
}

.bg-white\/10 > .form-overlay-error,
[class*="backdrop-blur"] > .form-overlay-error {
    background: rgba(127, 29, 29, 0.80);
}

/* Animations */
@keyframes formOverlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes formOverlayFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.form-overlay-fade-out {
    animation: formOverlayFadeOut 0.5s ease forwards;
}

/* Form focus states */
form input:focus,
form textarea:focus,
form select:focus {
    outline: none;
    ring-width: 2px;
    ring-color: #3b82f6;
}

/* Smooth transitions */
form input,
form textarea,
form select,
form button {
    transition: all 0.2s ease-in-out;
}

/* Disabled state */
form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

