/* Toast Container Positioning */
.toast-container {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    max-height: 100vh;
    overflow-y: auto;
    padding: 16px;
    pointer-events: none;
    /* Allow clicking through container */
    /* Fix for the vertical scrollbar issue */
    overflow-x: hidden;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.toast-container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Container Positions */
.toast-container.top-right {
    top: 0;
    right: 0;
}

.toast-container.top-left {
    top: 0;
    left: 0;
}

.toast-container.bottom-right {
    bottom: 0;
    right: 0;
}

.toast-container.bottom-left {
    bottom: 0;
    left: 0;
}

.toast-container.top-center {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}

.toast-container.bottom-center {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}

/* Toast Notification */
.toast-notification {
    display: flex;
    align-items: flex-start;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    min-width: 300px;
    max-width: 490px;
    pointer-events: auto;
    /* Make toast clickable */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-left: 4px solid;
    position: relative;
    overflow: hidden;
    /* Fix for potential overflow issues */
    box-sizing: border-box;
    width: calc(100% - 8px);
    /* Prevent horizontal overflow */
    margin-right: 8px;
    /* Add some margin to prevent touching the edge */
}

/* Toast Animation States */
.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-notification.hiding {
    opacity: 0;
    transform: translateY(-20px);
}

/* Toast Types */
.toast-notification.success {
    border-left-color: #10b981;
}

.toast-notification.error {
    border-left-color: #ef4444;
}

.toast-notification.warning {
    border-left-color: #f59e0b;
}

.toast-notification.info {
    border-left-color: #3b82f6;
}

/* Toast Icon */
.toast-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-notification.success .toast-icon {
    color: #10b981;
}

.toast-notification.error .toast-icon {
    color: #ef4444;
}

.toast-notification.warning .toast-icon {
    color: #f59e0b;
}

.toast-notification.info .toast-icon {
    color: #3b82f6;
}

/* Toast Content */
.toast-content {
    flex: 1;
    margin-right: 8px;
}

.toast-content p {
    margin: 0;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.5;
}

/* Close Button */
.toast-close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #0f172a;
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.5));
    width: 100%;
    transform-origin: left;
    animation: progress-animation linear forwards;
    /* Fix for the vertical line bug */
    transform: scaleX(1);
    will-change: transform, width;
}

.toast-notification.success .toast-progress {
    background: linear-gradient(to right, rgba(16, 185, 129, 0.3), rgba(16, 185, 129, 0.7));
}

.toast-notification.error .toast-progress {
    background: linear-gradient(to right, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.7));
}

.toast-notification.warning .toast-progress {
    background: linear-gradient(to right, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.7));
}

.toast-notification.info .toast-progress {
    background: linear-gradient(to right, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.7));
}

/* Pause animation on hover */
.toast-notification.paused .toast-progress {
    animation-play-state: paused;
}

@keyframes progress-animation {
    0% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark)   {
    .toast-notification {
        background-color: #1e293b;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .toast-content p {
        color: #f1f5f9;
    }

    .toast-close {
        color: #94a3b8;
    }

    .toast-close:hover {
        color: #f1f5f9;
    }
}

/* Light Mode Support */
@media (prefers-color-scheme: light)   {
    .toast-notification {
        background-color: #1e293b;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .toast-content p {
        color: #f1f5f9;
    }

    .toast-close {
        color: #94a3b8;
    }

    .toast-close:hover {
        color: #f1f5f9;
    }
}

/* Responsive Adjustments */
@media (max-width: 576px) {
    .toast-container {
        width: 100%;
        padding: 10px;
    }

    .toast-notification {
        min-width: auto;
        width: 100%;
    }

    .toast-container.top-center,
    .toast-container.bottom-center {
        width: 90%;
    }
}