/**
 * Global Toast Notification System
 * Usage: showToast('Message', 'success|error|info')
 * Supports light and dark themes via data-theme attribute
 */

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    width: auto;
    max-width: calc(100vw - 20px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

/* Toast */
.toast-container .toast {
    display: flex !important;
    opacity: 1 !important;
    width: auto;
    font-size: inherit;
    color: inherit;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    padding: 16px 20px;
    background: color-mix(in srgb, var(--primary, #046FAD) 8%, #FFFFFF);
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--primary, #046FAD) 30%, transparent);
    box-shadow: 0 6px 16px rgba(4, 111, 173, 0.14);
    pointer-events: all;
    animation: slideIn 0.3s ease-out;
    transition: all 0.3s ease;
}

.toast-container .toast.hiding {
    animation: slideOut 0.3s ease-out forwards;
}

/* Dark Mode */
[data-theme="dark"] .toast-container .toast {
    background: color-mix(in srgb, var(--primary, #046FAD) 14%, #12161f);
    border-color: color-mix(in srgb, var(--primary, #046FAD) 35%, transparent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-icon i {
    font-size: 16px;
}

/* Success Toast */
.toast-container .toast.success .toast-icon,
.toast-container .toast.error .toast-icon,
.toast-container .toast.info .toast-icon,
.toast-container .toast.warning .toast-icon {
    background: var(--primary, #046FAD);
}

.toast-container .toast.success .toast-icon i,
.toast-container .toast.error .toast-icon i,
.toast-container .toast.info .toast-icon i,
.toast-container .toast.warning .toast-icon i {
    color: #FFFFFF;
}

/* Toast Message */
.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: color-mix(in srgb, var(--text-primary, #1F2937) 92%, var(--primary, #046FAD));
    line-height: 1.4;
}

[data-theme="dark"] .toast-message {
    color: #F2F7FB;
}

/* Toast Close Button */
.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #6B7280;
    transition: all 0.2s;
    padding: 0;
}

.toast-close:hover {
    background: #F3F4F6;
    color: #1F2937;
}

[data-theme="dark"] .toast-close {
    color: #9CA3AF;
}

[data-theme="dark"] .toast-close:hover {
    background: #3C3C3E;
    color: #F9FAFB;
}

.toast-close i {
    font-size: 18px;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        align-items: stretch;
    }

    .toast-container .toast {
        min-width: auto;
        max-width: none;
        width: 100%;
    }

    @keyframes slideIn {
        from {
            transform: translateY(-100px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    @keyframes slideOut {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(-100px);
            opacity: 0;
        }
    }
}
