/* Toast Notification System */
.toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    max-width: 400px;
    width: auto !important;
    pointer-events: none;
    /* Ensure it's above everything */
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override any potential conflicts */
.toast-container.toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
}

.custom-toast {
    min-width: 300px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.3s ease-out;
    pointer-events: auto;
    position: relative !important;
}

.custom-toast.hiding {
    animation: slideOutRight 0.3s ease-in;
}

.custom-toast .toast-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    border-radius: 8px 8px 0 0;
}

.custom-toast .toast-body {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
}

/* Success Toast */
.custom-toast.toast-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.custom-toast.toast-success .toast-header {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.custom-toast.toast-success .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Error Toast */
.custom-toast.toast-error {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
    color: white;
}

.custom-toast.toast-error .toast-header {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.custom-toast.toast-error .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Warning Toast */
.custom-toast.toast-warning {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #212529;
}

.custom-toast.toast-warning .toast-header {
    background: rgba(0, 0, 0, 0.1);
    color: #212529;
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Info Toast */
.custom-toast.toast-info {
    background: linear-gradient(135deg, #17a2b8, #3498db);
    color: white;
}

.custom-toast.toast-info .toast-header {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.custom-toast.toast-info .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* RTL Support */
[dir="rtl"] .toast-container,
html[dir="rtl"] .toast-container,
body[dir="rtl"] .toast-container {
    right: auto !important;
    left: 20px !important;
}

[dir="rtl"] .toast-container.toast-container,
html[dir="rtl"] .toast-container.toast-container,
body[dir="rtl"] .toast-container.toast-container {
    right: auto !important;
    left: 20px !important;
}

[dir="rtl"] .custom-toast {
    animation: slideInLeft 0.3s ease-out;
}

[dir="rtl"] .custom-toast.hiding {
    animation: slideOutLeft 0.3s ease-in;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 576px) {
    .toast-container {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: none !important;
        width: auto !important;
    }
    
    [dir="rtl"] .toast-container {
        left: 10px !important;
        right: 10px !important;
    }
    
    .custom-toast {
        min-width: auto;
        width: 100%;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .custom-toast.toast-warning {
        color: white;
    }
    
    .custom-toast.toast-warning .toast-header {
        background: rgba(255, 255, 255, 0.1);
        color: white;
        border-bottom-color: rgba(255, 255, 255, 0.2);
    }
    
    .custom-toast.toast-warning .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
    }
}

[data-bs-theme="dark"] .custom-toast.toast-warning {
    color: white;
}

[data-bs-theme="dark"] .custom-toast.toast-warning .toast-header {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .custom-toast.toast-warning .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Additional positioning safeguards */
.toast-container[aria-live="polite"] {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
}

/* Ensure container doesn't get moved by other CSS */
body .toast-container,
#app .toast-container,
.container .toast-container,
.row .toast-container,
.col .toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: auto !important;
}

/* RTL versions */
[dir="rtl"] body .toast-container,
[dir="rtl"] #app .toast-container,
[dir="rtl"] .container .toast-container,
[dir="rtl"] .row .toast-container,
[dir="rtl"] .col .toast-container,
html[dir="rtl"] body .toast-container,
html[dir="rtl"] #app .toast-container,
html[dir="rtl"] .container .toast-container,
html[dir="rtl"] .row .toast-container,
html[dir="rtl"] .col .toast-container {
    right: auto !important;
    left: 20px !important;
}