/* ---------- TOAST SYSTEM ---------- */
.toast-container {
    position: fixed;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
    gap: 0;
}

.toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #f1f5f9;
    padding: 1rem 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    min-width: 320px;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.3s ease,
        margin-top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity, margin-top;
    position: relative;
    transform-origin: top center;
    margin-top: 0;
}

/* Front toast styling */
.toast-container .toast:first-child {
    transform: translateY(0) scale(1);
    opacity: 1;
    z-index: 100;
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    margin-top: 0;
}

.toast-container .toast:first-child::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.toast-container .toast:not(:first-child) {
    transform-origin: top center;
    border-color: rgba(255, 255, 255, 0.04);
}

/* ----- ENTRY ANIMATION ----- */
.toast:not(.removing) {
    animation: toastSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes toastSlideUp {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.85) rotateX(-5deg);
        filter: blur(8px);
    }
    40% {
        opacity: 1;
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0deg);
        filter: blur(0px);
    }
}

/* ----- EXIT ANIMATION ----- */
.toast.removing {
    animation: toastSlideOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0deg);
        filter: blur(0px);
        max-height: 200px;
        margin-top: 0;
        padding: 1rem 1.5rem;
        opacity: 1;
    }
    30% {
        opacity: 0.5;
        transform: translateY(-10px) scale(0.95) rotateX(-3deg);
        filter: blur(2px);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.85) rotateX(-5deg);
        filter: blur(8px);
        max-height: 0;
        margin-top: -70px;
        padding: 0 1.5rem;
        opacity: 0;
    }
}

/* ----- TOAST VARIANTS ----- */
.toast.toast-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
}

.toast.toast-error::before {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(220, 38, 38, 0.1));
}

.toast.toast-error:first-child {
    box-shadow: 0 8px 40px rgba(239, 68, 68, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.toast.toast-warning {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.25);
}

.toast.toast-warning::before {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.1));
}

.toast.toast-warning:first-child {
    box-shadow: 0 8px 40px rgba(251, 191, 36, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.toast.toast-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
}

.toast.toast-success::before {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(22, 163, 74, 0.1));
}

.toast.toast-success:first-child {
    box-shadow: 0 8px 40px rgba(34, 197, 94, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ----- TOAST CONTENT ----- */
.toast-message {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 400;
    color: #e2e8f0;
    letter-spacing: 0.2px;
    padding: 2px 0;
}

.toast-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    padding: 0;
    color: #f1f5f9;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 40px;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    font-weight: 300;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ff0000;
    transform: rotate(90deg) scale(1.1);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ----- COUNTER BADGE (top right) ----- */
.toast-counter {
    position: absolute;
    top: -10px;
    right: -8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4),
        0 0 30px rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.toast-counter::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 40px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.toast-counter .icon {
    font-size: 0.7rem;
    margin-right: 4px;
}

.toast-counter.pulse {
    animation: counterPulse 0.4s ease;
}

@keyframes counterPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 500px) {
    .toast {
        min-width: 280px;
        max-width: 90vw;
        padding: 0.9rem 1.2rem;
        border-radius: 16px;
    }
    .toast-counter {
        font-size: 0.6rem;
        min-width: 24px;
        height: 24px;
        padding: 0 8px;
        top: -8px;
        right: -6px;
    }
    @keyframes toastSlideOut {
        0% {
            opacity: 1;
            transform: translateY(0) scale(1);
            max-height: 200px;
            padding: 0.9rem 1.2rem;
        }
        100% {
            opacity: 0;
            transform: translateY(-30px) scale(0.85);
            max-height: 0;
            margin-top: -60px;
            padding: 0 1.2rem;
        }
    }
}