/**
 * Flash Messages - Animation Styles
 *
 * Provides slide + fade animations for flash messages
 * with accessibility support for reduced motion preferences
 */

/* Flash messages container */
#flash-messages-container {
    position: relative;
    z-index: 1040; /* Below modals (1050), above content */
    overflow: visible; /* Prevent scrollbar during animations */
}

/* Remove padding when empty to prevent extra spacing */
#flash-messages-container:empty {
    padding: 0 !important;
    margin: 0 !important;
}

/* Flash message base styles */
.flash-message {
    position: relative;
    overflow: hidden; /* Back to hidden to clip content properly */
    transform-origin: top center;
    margin-bottom: 0.75rem;
}

/* Slide-in animation (initial state) */
.flash-message.flash-entering {
    opacity: 0;
    transform: translateY(-20px);
}

/* Slide-in animation (active) */
.flash-message.flash-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity var(--flash-animation-speed, 300ms) ease-out,
        transform var(--flash-animation-speed, 300ms) ease-out;
}

/* Slide-out animation (leaving) */
.flash-message.flash-leaving {
    opacity: 0;
    transform: translateY(-10px);
    margin-bottom: 0;
    transition:
        opacity var(--flash-animation-speed, 300ms) ease-in,
        transform var(--flash-animation-speed, 300ms) ease-in,
        margin-bottom var(--flash-animation-speed, 300ms) ease-in;
}

/* No animations (fallback/disabled) */
.flash-message.flash-no-animation {
    opacity: 1;
    transform: none;
    max-height: none;
}

/* Hover behavior - visual indicator */
.flash-message:hover {
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

/* Progress bar for auto-hide (optional visual indicator) */
.flash-message.flash-auto-hiding::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    width: 100%;
    transform-origin: left;
    animation: flash-progress var(--flash-timeout, 5000ms) linear forwards;
}

@keyframes flash-progress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Pause progress bar on hover */
.flash-message:hover.flash-auto-hiding::after {
    animation-play-state: paused;
}

/* Message text wrapping */
.flash-message-text {
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Only for extremely long messages (rare case) - add this class manually if needed */
.flash-message.flash-message-long {
    max-height: 300px;
    overflow-y: auto;
}

/* Scrollbar styling for long messages (WebKit browsers) */
.flash-message::-webkit-scrollbar {
    width: 6px;
}

.flash-message::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.flash-message::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.flash-message::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Accessibility: Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .flash-message,
    .flash-message.flash-entering,
    .flash-message.flash-enter-active,
    .flash-message.flash-leaving {
        transition: none !important;
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        margin-bottom: 0.75rem !important;
    }

    .flash-message:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .flash-message.flash-auto-hiding::after {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .flash-message {
        border: 2px solid currentColor;
    }

    .flash-message.flash-auto-hiding::after {
        height: 4px;
        opacity: 0.5;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 576px) {
    #flash-messages-container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .flash-message {
        font-size: 0.9rem;
    }

    .flash-message .ph {
        font-size: 1.2rem;
    }
}

/* Print styles - hide flash messages */
@media print {
    #flash-messages-container,
    .flash-message {
        display: none !important;
    }
}

/* Collapse the container when there are no messages so it doesn't reserve
   vertical space (the wrapper keeps px-3 pt-3 padding even when empty). */
#flash-messages-container:empty {
    padding: 0 !important;
}
