/* ===================================
   Flash Message Popup - Purple Theme
   =================================== */

@keyframes flashSlideIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(0.95); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes flashSlideOut {
    0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(0.95); }
}

@keyframes flashProgressShrink {
    0% { width: 100%; }
    100% { width: 0%; }
}

@keyframes flashIconPop {
    0% { transform: scale(0) rotate(-15deg); }
    60% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes flashPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--flash-rgb), 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(var(--flash-rgb), 0); }
}

.flash-popup {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    width: 92%;
    max-width: 440px;
    pointer-events: auto;
}

.flash-popup[style*="display: none"] {
    display: block !important;
}

.flash-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px 14px;
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow:
        0 8px 32px rgba(0,0,0,0.12),
        0 2px 8px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.2);
    overflow: hidden;
    animation: flashSlideIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    direction: rtl;
    text-align: right;
}

.flash-card.flash-exit {
    animation: flashSlideOut 0.3s ease-in forwards;
}

/* Success */
.flash-card.flash-success {
    background: linear-gradient(135deg, rgba(139,92,246,0.92) 0%, rgba(124,58,237,0.95) 100%);
    --flash-rgb: 139,92,246;
    color: #fff;
}

/* Danger */
.flash-card.flash-danger {
    background: linear-gradient(135deg, rgba(168,85,247,0.92) 0%, rgba(147,51,234,0.95) 100%);
    --flash-rgb: 168,85,247;
    color: #fff;
}

/* Warning */
.flash-card.flash-warning {
    background: linear-gradient(135deg, rgba(192,132,252,0.92) 0%, rgba(168,85,247,0.95) 100%);
    --flash-rgb: 192,132,252;
    color: #fff;
}

/* Info */
.flash-card.flash-info {
    background: linear-gradient(135deg, rgba(99,102,241,0.92) 0%, rgba(79,70,229,0.95) 100%);
    --flash-rgb: 99,102,241;
    color: #fff;
}

/* Icon container */
.flash-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    animation: flashIconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

.flash-icon i {
    font-size: 1.15rem;
}

.flash-success .flash-icon { animation-name: flashIconPop, flashPulse; animation-duration: 0.5s, 2s; animation-delay: 0.15s, 0.6s; animation-iteration-count: 1, infinite; }

/* Content */
.flash-content {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.flash-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0 0 2px;
    line-height: 1.3;
}

.flash-message {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.92;
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Close button */
.flash-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    padding: 0;
    margin-top: 2px;
}

.flash-close:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.flash-close i {
    font-size: 0.7rem;
}

/* Progress bar */
.flash-progress {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.25);
    border-radius: 0 0 20px 20px;
    overflow: hidden;
}

.flash-progress-bar {
    height: 100%;
    background: rgba(255,255,255,0.7);
    border-radius: inherit;
    animation: flashProgressShrink 5s linear forwards;
}

/* Responsive */
@media (max-width: 480px) {
    .flash-popup {
        top: 16px;
        width: 94%;
        max-width: none;
    }
    .flash-card {
        padding: 14px 16px 12px;
        border-radius: 16px;
        gap: 10px;
    }
    .flash-icon {
        width: 36px;
        height: 36px;
        border-radius: 12px;
    }
}

/* Stacking: multiple toasts */
.flash-popup + .flash-popup {
    margin-top: 10px;
}
