/* ============================================
   TOASTR MODERN GRADIENT STYLING
   Beautiful toast notifications with gradients and animations
   ============================================ */

/* Override Toastr positioning */
#toast-container {
    z-index: 999999 !important;
    position: fixed !important;
    pointer-events: none !important;
}

#toast-container > div {
    pointer-events: auto !important;
}

/* Toast container positioning */
#toast-container.toast-top-right {
    top: 90px !important;
    right: 20px !important;
    position: fixed !important;
}

@media (max-width: 768px) {
    #toast-container.toast-top-right {
        top: 80px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: calc(100% - 20px);
    }

    #toast-container > div {
        max-width: none;
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ============================================
   SUCCESS TOAST - Green Gradient
   ============================================ */
#toast-container > .toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%) !important;
    background-image: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%) !important;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-left: 5px solid #34d399 !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #ffffff !important;
}

#toast-container > .toast-success:hover {
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

#toast-container > .toast-success:before {
    font-family: 'bootstrap-icons' !important;
    content: "\f26b" !important; /* bi-check-circle-fill */
    font-size: 28px !important;
    font-weight: normal !important;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    animation: iconPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    display: inline-block !important;
}

/* ============================================
   ERROR TOAST - Red Gradient
   ============================================ */
#toast-container > .toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%) !important;
    background-image: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%) !important;
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-left: 5px solid #f87171 !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #ffffff !important;
}

#toast-container > .toast-error:hover {
    box-shadow: 0 12px 40px rgba(239, 68, 68, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

#toast-container > .toast-error:before {
    font-family: 'bootstrap-icons' !important;
    content: "\f659" !important; /* bi-x-circle-fill */
    font-size: 28px !important;
    font-weight: normal !important;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    animation: iconShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
    display: inline-block !important;
}

/* ============================================
   WARNING TOAST - Orange/Amber Gradient
   ============================================ */
#toast-container > .toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%) !important;
    background-image: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%) !important;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-left: 5px solid #fbbf24 !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #ffffff !important;
}

#toast-container > .toast-warning:hover {
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

#toast-container > .toast-warning:before {
    font-family: 'bootstrap-icons' !important;
    content: "\f33a" !important; /* bi-exclamation-triangle-fill */
    font-size: 28px !important;
    font-weight: normal !important;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    animation: iconBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    display: inline-block !important;
}

/* ============================================
   INFO TOAST - Blue Gradient
   ============================================ */
#toast-container > .toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%) !important;
    background-image: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%) !important;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-left: 5px solid #60a5fa !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #ffffff !important;
}

#toast-container > .toast-info:hover {
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

#toast-container > .toast-info:before {
    font-family: 'bootstrap-icons' !important;
    content: "\f431" !important; /* bi-info-circle-fill */
    font-size: 28px !important;
    font-weight: normal !important;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    animation: iconPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    display: inline-block !important;
}

/* ============================================
   TOAST GENERAL STYLING
   ============================================ */
#toast-container > div {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
    border-radius: 12px !important;
    padding: 18px 50px 22px 24px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    min-width: 320px !important;
    font-size: 15px !important;
    backdrop-filter: blur(10px) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    overflow: hidden !important;
}

#toast-container > div:hover {
    cursor: pointer;
    transform: translateY(-2px) scale(1.02) !important;
}

/* Title styling */
#toast-container > .toast .toast-title {
    font-weight: 700;
    font-size: 16px !important;
    margin-bottom: 6px;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

/* Message styling */
#toast-container > .toast .toast-message {
    font-size: 14px !important;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 400;
    margin-bottom: 0 !important;
}

/* Badge styling for detailed messages */
#toast-container .toast-message .bi {
    vertical-align: middle;
}

#toast-container .toast-message > div {
    color: #ffffff !important;
}

#toast-container .toast-message span[style*="background"] {
    white-space: nowrap;
}

/* Changes section styling for update notifications */
#toast-container .toast-message .bi-arrow-right {
    opacity: 0.8;
    font-size: 0.85rem;
}

/* Strikethrough animation for old values in changes */
#toast-container .toast-message [style*="opacity: 0.7"] {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

/* Close button styling - Fixed to work properly */
#toast-container > div > .toast-close-button {
    position: relative !important;
    float: right !important;
    font-size: 20px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    opacity: 0.8 !important;
    transition: all 0.2s ease !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer !important;
    margin-left: 15px !important;
    margin-top: -3px !important;
}

#toast-container > div > .toast-close-button:hover,
#toast-container > div > .toast-close-button:focus {
    opacity: 1 !important;
    transform: scale(1.2) rotate(90deg) !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

/* ============================================
   ENHANCED PROGRESS BAR WITH TIMER
   ============================================ */

/* Progress bar container - More prominent and visible */
#toast-container > div .toast-progress {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 6px !important;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.8) 25%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.8) 75%,
        rgba(255, 255, 255, 0.9) 100%) !important;
    background-size: 200% 100% !important;
    border-radius: 0 0 12px 12px !important;
    overflow: hidden !important;
    opacity: 1 !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 
                inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
    animation: shimmer 2s infinite linear !important;
}

/* Success toast progress bar */
#toast-container > .toast-success .toast-progress {
    background: linear-gradient(90deg, 
        rgba(52, 211, 153, 0.95) 0%,
        rgba(255, 255, 255, 0.9) 25%,
        rgba(52, 211, 153, 0.95) 50%,
        rgba(255, 255, 255, 0.9) 75%,
        rgba(52, 211, 153, 0.95) 100%) !important;
    background-size: 200% 100% !important;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.8), 
                inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
}

/* Error toast progress bar */
#toast-container > .toast-error .toast-progress {
    background: linear-gradient(90deg, 
        rgba(248, 113, 113, 0.95) 0%,
        rgba(255, 255, 255, 0.9) 25%,
        rgba(248, 113, 113, 0.95) 50%,
        rgba(255, 255, 255, 0.9) 75%,
        rgba(248, 113, 113, 0.95) 100%) !important;
    background-size: 200% 100% !important;
    box-shadow: 0 0 15px rgba(248, 113, 113, 0.8), 
                inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
}

/* Warning toast progress bar */
#toast-container > .toast-warning .toast-progress {
    background: linear-gradient(90deg, 
        rgba(251, 191, 36, 0.95) 0%,
        rgba(255, 255, 255, 0.9) 25%,
        rgba(251, 191, 36, 0.95) 50%,
        rgba(255, 255, 255, 0.9) 75%,
        rgba(251, 191, 36, 0.95) 100%) !important;
    background-size: 200% 100% !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.8), 
                inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
}

/* Info toast progress bar */
#toast-container > .toast-info .toast-progress {
    background: linear-gradient(90deg, 
        rgba(96, 165, 250, 0.95) 0%,
        rgba(255, 255, 255, 0.9) 25%,
        rgba(96, 165, 250, 0.95) 50%,
        rgba(255, 255, 255, 0.9) 75%,
        rgba(96, 165, 250, 0.95) 100%) !important;
    background-size: 200% 100% !important;
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.8), 
                inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
}

/* Shimmer animation for progress bar */
@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Pulse glow effect when progress bar is active */
@keyframes progressGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 
                    inset 0 1px 3px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 
                    inset 0 1px 5px rgba(255, 255, 255, 0.5);
    }
}

/* ============================================
   MODERN SEAMLESS ANIMATIONS
   ============================================ */

/* Fly-in animation - Smooth slide from right with fade and slight rotation */
@keyframes flyInRight {
    0% {
        transform: translate3d(120%, 0, 0) rotateZ(10deg) scale(0.8);
        opacity: 0;
        filter: blur(4px);
    }
    60% {
        transform: translate3d(-5%, 0, 0) rotateZ(-2deg) scale(1.02);
        opacity: 0.9;
        filter: blur(0px);
    }
    100% {
        transform: translate3d(0, 0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
        filter: blur(0px);
    }
}

/* Fly-out animation - Smooth slide to right with fade and scale down */
@keyframes flyOutRight {
    0% {
        transform: translate3d(0, 0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
        filter: blur(0px);
    }
    40% {
        transform: translate3d(5%, 0, 0) rotateZ(2deg) scale(0.98);
        opacity: 0.7;
        filter: blur(0px);
    }
    100% {
        transform: translate3d(120%, 0, 0) rotateZ(-10deg) scale(0.8);
        opacity: 0;
        filter: blur(4px);
    }
}

/* Icon pop-in animation for success and info */
@keyframes iconPopIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
    }
    70% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Icon shake animation for errors */
@keyframes iconShake {
    0%, 100% {
        transform: translateX(0) scale(1) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px) scale(1.1) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px) scale(1.1) rotate(5deg);
    }
}

/* Icon bounce animation for warnings */
@keyframes iconBounce {
    0% {
        transform: translateY(-50px) scale(0.5);
        opacity: 0;
    }
    40% {
        transform: translateY(0) scale(1.2);
        opacity: 1;
    }
    60% {
        transform: translateY(-10px) scale(0.95);
    }
    80% {
        transform: translateY(0) scale(1.05);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

/* Pulse animation for emphasis */
@keyframes subtlePulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 12px 40px rgba(16, 185, 129, 0.6), 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: scale(1.01);
    }
}

/* Apply fly-in animation only when toast first appears - don't override toastr's removal */
#toast-container > .toast {
    animation: flyInRight 0.5s cubic-bezier(0.68, -0.35, 0.265, 1.35) forwards !important;
}

/* Let toastr handle the hiding with its built-in mechanism */
#toast-container > .toast[style*="display: none"] {
    animation: flyOutRight 0.4s cubic-bezier(0.6, 0.04, 0.98, 0.335) forwards !important;
}

/* Add subtle pulse to success toasts - but only during display, not removal */
#toast-container > .toast-success:not([style*="display: none"]) {
    animation: flyInRight 0.5s cubic-bezier(0.68, -0.35, 0.265, 1.35), subtlePulse 2s ease-in-out 0.5s !important;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 576px) {
    #toast-container > div {
        min-width: 280px !important;
        padding: 16px 45px 20px 20px !important;
        font-size: 14px !important;
    }

    #toast-container > .toast .toast-title {
        font-size: 15px !important;
    }

    #toast-container > .toast .toast-message {
        font-size: 13px !important;
    }
    
    #toast-container > .toast-success:before,
    #toast-container > .toast-error:before,
    #toast-container > .toast-warning:before,
    #toast-container > .toast-info:before {
        font-size: 24px !important;
    }
    
    #toast-container > div .toast-progress {
        height: 5px !important;
    }
    
    #toast-container > div > .toast-close-button {
        font-size: 18px !important;
    }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    #toast-container > div {
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    }
}

/* ============================================
   ACCESSIBILITY - Reduced motion support
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    #toast-container > .toast {
        animation: none !important;
        transition: opacity 0.3s ease !important;
    }
    
    #toast-container > .toast-success:before,
    #toast-container > .toast-error:before,
    #toast-container > .toast-warning:before,
    #toast-container > .toast-info:before {
        animation: none !important;
    }
    
    #toast-container > div .toast-progress {
        animation: none !important;
    }
}
