/**
 * Form Auto-Save Status Message Styling
 * 
 * Provides consistent styling for form auto-save status messages
 * that appear in the bottom-right corner of the page.
 */

/* Base autosave status message styling */
#form-autosave-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 9999;
    max-width: 250px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    transform: translateY(0);
    opacity: 1;
    line-height: 1.4;
    word-wrap: break-word;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Status message variants */
#form-autosave-status.autosave-status-info {
    background: rgba(227, 242, 253, 0.95);
    color: #1565c0;
    border: 1px solid #bbdefb;
}

#form-autosave-status.autosave-status-success {
    background: rgba(232, 245, 232, 0.95);
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

#form-autosave-status.autosave-status-error {
    background: rgba(255, 235, 238, 0.95);
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Animation states */
#form-autosave-status.autosave-entering {
    opacity: 0;
    transform: translateY(100%);
}

#form-autosave-status.autosave-leaving {
    opacity: 0;
    transform: translateY(100%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #form-autosave-status {
        left: 20px;
        right: 20px;
        max-width: none;
        font-size: 11px;
        padding: 6px 10px;
        bottom: 20px;
    }
}

@media (max-width: 480px) {
    #form-autosave-status {
        bottom: 10px;
        left: 10px;
        right: 10px;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #form-autosave-status.autosave-status-info {
        background: rgba(30, 58, 138, 0.95);
        color: #bfdbfe;
        border-color: #3b82f6;
    }

    #form-autosave-status.autosave-status-success {
        background: rgba(22, 101, 52, 0.95);
        color: #bbf7d0;
        border-color: #22c55e;
    }

    #form-autosave-status.autosave-status-error {
        background: rgba(153, 27, 27, 0.95);
        color: #fecaca;
        border-color: #ef4444;
    }

    #form-autosave-status {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #form-autosave-status {
        border-width: 2px;
        font-weight: 600;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    #form-autosave-status.autosave-status-info {
        background: #000;
        color: #00f;
        border-color: #00f;
    }

    #form-autosave-status.autosave-status-success {
        background: #000;
        color: #0f0;
        border-color: #0f0;
    }

    #form-autosave-status.autosave-status-error {
        background: #000;
        color: #f00;
        border-color: #f00;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #form-autosave-status {
        transition: opacity 0.1s ease;
        transform: none;
    }

    #form-autosave-status.autosave-entering,
    #form-autosave-status.autosave-leaving {
        transform: none;
    }
}

/* Print media - hide autosave messages */
@media print {
    #form-autosave-status {
        display: none;
    }
}

/* Position adjustment when both CSRF and autosave messages are present */
body:has(#csrf-status-message) #form-autosave-status {
    bottom: 80px; /* Stack below CSRF messages */
}

/* Subtle pulse animation for active saving */
@keyframes autosave-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#form-autosave-status.autosave-saving {
    animation: autosave-pulse 1.5s ease-in-out infinite;
}

/* Focus visible support for accessibility */
#form-autosave-status:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}