/**
 * Modern Toast Notification Styles
 * Shared CSS for ERP System
 * 
 * Usage:
 * <link rel="stylesheet" href="css/shared/modern-toast.css">
 * 
 * Compatible with: Bootstrap 5.x, Font Awesome 6.x
 * Responsive: Yes
 * Browser Support: Modern browsers with CSS Grid/Flexbox support
 */

/* Toast Container */
.modern-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    pointer-events: none;
}

/* Base Toast Styles */
.modern-toast {
    position: relative;
    margin-bottom: 12px;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    pointer-events: auto;
    overflow: hidden;
    min-width: 320px;
    max-width: 400px;
    
    /* Smooth entrance animation */
    animation: toastSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform: translateX(100%);
    opacity: 0;
}

/* Toast Types - Bootstrap Color System */
.modern-toast.success {
    background: rgba(25, 135, 84, 0.95);
    color: white;
    border-left: 4px solid rgba(25, 135, 84, 1);
}

.modern-toast.error {
    background: rgba(220, 53, 69, 0.95);
    color: white;
    border-left: 4px solid rgba(220, 53, 69, 1);
}

.modern-toast.warning {
    background: rgba(255, 193, 7, 0.95);
    color: #212529;
    border-left: 4px solid rgba(255, 193, 7, 1);
}

.modern-toast.info {
    background: rgba(13, 202, 240, 0.95);
    color: white;
    border-left: 4px solid rgba(13, 202, 240, 1);
}

.modern-toast.primary {
    background: rgba(13, 110, 253, 0.95);
    color: white;
    border-left: 4px solid rgba(13, 110, 253, 1);
}

/* Toast Content Layout */
.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.toast-icon {
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
    padding-right: 8px;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 14px;
}

.toast-message {
    font-weight: 400;
    opacity: 0.95;
    font-size: 13px;
}

/* Close Button */
.toast-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.modern-toast.warning .toast-close {
    color: rgba(33, 37, 41, 0.7);
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.05);
}

.modern-toast.warning .toast-close:hover {
    background: rgba(33, 37, 41, 0.1);
    color: #212529;
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.modern-toast.warning .toast-progress {
    background: rgba(33, 37, 41, 0.2);
}

.toast-progress-bar {
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    border-radius: inherit;
    transition: width 0.1s linear;
}

.modern-toast.warning .toast-progress-bar {
    background: rgba(33, 37, 41, 0.7);
}

/* Animations */
@keyframes toastSlideIn {
    0% {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }
    50% {
        transform: translateX(-8px) scale(1.02);
        opacity: 0.8;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
        max-height: 200px;
        margin-bottom: 12px;
    }
    50% {
        transform: translateX(50%) scale(0.95);
        opacity: 0.3;
    }
    100% {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

.modern-toast.removing {
    animation: toastSlideOut 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

/* Hover Effect */
.modern-toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.modern-toast:hover .toast-progress-bar {
    animation-play-state: paused;
}

/* Responsive Design */
@media (max-width: 480px) {
    .modern-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .modern-toast {
        min-width: auto;
        max-width: none;
        margin-bottom: 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modern-toast {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modern-toast {
        animation: none;
        transform: none;
        opacity: 1;
    }
    
    .modern-toast.removing {
        animation: none;
        opacity: 0;
    }
    
    .modern-toast:hover {
        transform: none;
    }
}

/* Stack multiple toasts nicely */
.modern-toast:nth-child(1) { z-index: 10; }
.modern-toast:nth-child(2) { z-index: 9; transform: translateY(-4px) scale(0.98); }
.modern-toast:nth-child(3) { z-index: 8; transform: translateY(-8px) scale(0.96); }
.modern-toast:nth-child(4) { z-index: 7; transform: translateY(-12px) scale(0.94); }
.modern-toast:nth-child(n+5) { display: none; }

/* Custom theme support */
.modern-toast.custom {
    background: var(--toast-bg, rgba(108, 117, 125, 0.95));
    color: var(--toast-color, white);
    border-left: 4px solid var(--toast-border, rgb(108, 117, 125));
}

/* Action button styling */
.toast-action {
    margin-top: 8px;
}

.toast-action .btn {
    font-size: 12px;
    padding: 4px 12px;
    margin-right: 8px;
}

/* Loading state */
.modern-toast.loading .toast-icon::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: toast-spin 1s linear infinite;
}

@keyframes toast-spin {
    to {
        transform: rotate(360deg);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modern-toast {
        border: 2px solid currentColor;
        box-shadow: none;
    }
    
    .toast-progress-bar {
        background: currentColor;
    }
}